C++ codes ( please use Dev++ compiler )
please send the full program and please compile before send
linked list program with the delete function (and traverse)
void delNode(node** start, int delNum)
if there is no match, print an error message otherwise, delete node
do not forget the test plan and code
#include <iostream>
#include <cstdlib>
using namespace std;
// A linked list node
struct Node
{
int data;
struct Node *next;
};
void printList(struct Node *node)
{
while (node != NULL)
{
cout << " " << node->data << " ";
node = node->next;
}
}
/* Given a reference (pointer to pointer) to the head of a list
and a key,
deletes the first occurrence of key in linked list */
void delNodeLinkedList(struct Node **start, int delNum)
{
// Store head node
struct Node* temp = *start, *prev;
// If head node itself holds the delNum to be deleted
if (temp != NULL && temp->data == delNum)
{
*start = temp->next; // Changed head
free(temp); // free old head
return;
}
// Search for the delNum(key) to be deleted, keep track of
the
// previous node as we need to change 'prev->next'
while (temp != NULL && temp->data != delNum)
{
prev = temp;
temp = temp->next;
}
// If delNum(key) was not present in linked list
if (temp == NULL)
{
cout << "Element not found in
the linked list.\n\n";
return;
}
// Unlink the node from linked list
prev->next = temp->next;
free(temp); // Free memory
}
int main()
{
struct Node* start = NULL;
struct Node* second = NULL;
struct Node* third = NULL;
struct Node* fourth = NULL;
struct Node* fifth = NULL;
// allocate 3 nodes in the heap
start = (struct Node*)malloc(sizeof(struct Node));
second = (struct Node*)malloc(sizeof(struct Node));
third = (struct Node*)malloc(sizeof(struct Node));
fourth = (struct Node*)malloc(sizeof(struct Node));
fifth = (struct Node*)malloc(sizeof(struct Node));
start->data = 10; //assign data in first node
start->next = second; // Link first node with second
second->data = 20; //assign data to second node
second->next = third;
third->data = 30; //assign data to third node
third->next = fourth;
fourth->data = 40;
fourth->next = fifth;
fifth->data = 50;
fifth->next = NULL;
cout << "List elements: \n";
printList(start);
cout << "\n\nDeleting node with value: 40\n";
delNodeLinkedList(&start, 11);
printList(start);
}

If there is anything that you do not understand, or need more help with then please mention it in the comments section.
C++ codes ( please use Dev++ compiler ) please send the full program and please compile...
I'm having trouble getting this program to compile and run. It is in C++ Language and being run with CodeBlocks. Problem Statement: create and manage a linked list. Program will loop displaying a menu of user operations concerning the management of a linked list. Included will be: H create link at head R remove link at head T create link at tail K remove link at tail I remove link at ID S search...
PLEASE USE C++ Source Code
Attached is a linked list with 2 nodes. You can use this or
write a similar one. The assignment is to write 2 functions. One
function will add another node at the end of the list. The other
function will delete a node. Don't forget - No dangling pointers
!
Example linked source code attached below
#include<iostream>
using namespace std;
class Node
{
int data;
Node *next;
public:
void setdata(int d) {data = d;}
void...
Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially: void inputStringFromUser(char *prompt, char *s, int arraySize); void songNameDuplicate(char *songName); void songNameFound(char *songName); void songNameNotFound(char *songName); void songNameDeleted(char *songName); void artistFound(char *artist); void artistNotFound(char *artist); void printMusicLibraryEmpty(void); void printMusicLibraryTitle(void); const int MAX_LENGTH = 1024; You will write a program that maintains information about your...
part 1(do not write on note book and before send program compile it) void testStruct01() this function is called from main in main() call the function void test01() in the function void test01() 1. create a FootballTeam object 2. using 'cin', load the FootballTeam object 3. using 'cout', display (print) the FootballTeam object 4. output should look like the following ********** AFC East ********** Home Team XXXXXXXXXXXXXXXXXXXXXXXX Opponent team XXXXXXXXXXXXXXXXXXXXXXXX Home Team score XXXXXXXXXXXXXXXXXXXXXXXX Opponent team score XXXXXXXXXXXXXXXXXXXXXXXX part...
Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list */ void...
BELOW IS THE CODE I ALREADY HAVE
Linked List - Delete Modify Lab 5 and include the method to delete a node from the Linked List. In summary: 1) Add the method Delete 2) Method call to delete, with a number that IS in the list 3) Method call to delete, with a number that is NOT in the list - Be sure to include comments - Use meaningful identifier names (constants where appropriate) import java.io.*; 1/ Java program to...
Please fill in the code to reverse a linked list. IN C++ #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list...
CSCI 2010 Lab11 Link-Lists
Lab 11A Linked-Lists
Preparation
Create a Visual Studio C++ Project C2010Lab11A
Add the following to the project.
//LinkedList.cpp
#include <cstdlib>
#include "LinkedList.h"
using namespace std;
//---------------------------------------------------
//List Element Members
//---------------------------------------------------
ListElement::ListElement(int d, ListElement * n)
{
datum=d;
next=n;
}
int ListElement::getDatum () const
{
return datum;
}
ListElement const* ListElement::getNext () const
{
return next;
}
//---------------------------------------------------
//LinkedList Members
//---------------------------------------------------
LinkedList::LinkedList ()
{
head=NULL;
}
void LinkedList::insertItem(int item)
{
ListElement *currPtr = head;
ListElement *prevPtr =...
MUST USE C++ PLEASE READ THE QUESTION CAREFULLY ADD COMMENTS AND EXPLAIN THE CODES PLEASE. Given the following skeleton of an unsorted list class that uses an unsorted linked list: template < class ItemType > struct NodeType { ItemType item; NodeType* next; }; template < class ItemType > class UList { public: UList(); // default constrctor UList(const UList &x); // we implement copy constructor with deep copy UList& operator = (UList &x); // equal sign...
c++
File name: 2170 107b.ee Purpose: This program demonstrates the use of multi-linked lists. //This file contains the implementation file for the 2170_10_7b.h header file. This implementation uses a dynamic linked list structure implementing the // Multi ListClass object. The implementation uses nodes which have two pointer fields one to point to the next record by name (nextName) and one to point Ito the next record by account number(nextNum). The linked list is also maintained I with a dummy header...