1) Create a C++ function named insertNode to insert a new node with a given value into an exiting link list before the node having the value of xyz. 2) Create a c++ function named updateNode to update a node value with a new value. 3) Create a c++ function named displayNodes to print the link list node values. 4) Create a c++ function named moveNode to move any node with a give value to the very end of an exiting link list.
1. Create a C++ function named insertNode to insert a new node with a given value into an exiting link list before the node having the value of xyz. 2) Create a c++ function named updateNode to update a node value with a new value. 3) Create a c++ function named displayNodes to print the link list node values. 4) Create a c++ function named moveNode to move any node with a give value to the very end of an exiting link list.
1.create() function is used to create and insert value in link list one after another
2.insertNode() function is used to insert value to the before position of any existing node
3.updateNode() function is used to update a particular location value with new value
4.displayNode() function is used to display entire link list
5.moveNode() function is used to move any position value to the last of the link list.
6.Exit function is used to exit from all option.
#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
struct node
{
int info;
struct node * next;
} *front=NULL,*last=NULL,*p=NULL;
void create()
{
p = new(struct node);
cout<<"Enter the value:";
cin>>p->info;
fflush(stdin);
p->next=NULL;
if(front==NULL)
{
front=p;
}
else
{
last->next=p;
}
last=p;
}
void insertNode()
{
int val, pos, i;
if (front == NULL)
{
cout<<endl<<"The next list is empty"<<endl;
return;
}
struct node *temp,*prev,*next,*p;
temp=front;
cout<<endl<<"Enter the node postion before which new
node will be added: ";
cin>>pos;
cout<<endl<<"Enter the new node value: ";
cin>>val;
for(i=1;i<=pos;i++)
{
if(i==pos)
{
p=new node;
p->info=val;
prev->next=p;
p->next=temp;
break;
}
else
{
prev=temp;
temp=temp->next;
}
}
}
void displayNode()
{
if(front==NULL)
{
cout<<endl<<"no element
to be displayed"<<endl;
}
else
{
struct node *temp=front;
cout<<"elements in link list
are"<<endl;
while(temp!=NULL)
{
cout<<"\t"<<temp->info;
temp=temp->next;
}
}
}
void updateNode()
{
int val, pos, i;
if (front == NULL)
{
cout<<endl<<"The next list is empty"<<endl;
return;
}
cout<<endl<<"Enter the node postion to be updated:
";
cin>>pos;
cout<<endl<<"Enter the new value: ";
cin>>val;
i=1;
struct node *temp, *ptr;
temp = front;
while(temp!=NULL)
{
if(i==pos)
{
temp->info=val;
temp=temp->next;
break;
}
else
{
i++;
temp=temp->next;
}
}
cout<<"Node value is Updated"<<endl;
}
void moveNode()
{
int val, pos, i;
cout<<endl<<"Enter the postion of the node to be moved:
";
cin>>pos;
struct node *temp,*prev,*next,*p;
temp=front;
for(i=1;i<=pos;i++)
{
if(i==pos)
{
val=temp->info;
prev->next=next;
break;
}
else
{
prev=temp;
temp=temp->next;
next=temp->next;
}
}
temp=front;
while(temp!=NULL)
{
temp=temp->next;
if(temp->next==NULL)
{
p=new node;
p->info=val;
temp->next=p;
p->next=NULL;
break;
}
}
}
int main()
{
int ch;
char ch1;
do
{
cout<<"1.Insert"<<endl;
cout<<"2. Insert before the
node"<<endl;
cout<<"3.Update"<<endl;
cout<<"4.Display"<<endl;
cout<<"5.Move"<<endl;
cout<<"6.Exit"<<endl;
cout<<"Enter the choice:";
cin>>ch;
switch(ch)
{
case 1:
create();
break;
case 2:
insertNode();
break;
case 3:
updateNode();
break;
case 4:
displayNode();
break;
case 5:
moveNode();
break;
case 6:
exit;
break;
default:
cout<<endl<<"Wrong option[ Enter from
1,2,3,4,5,6]"<<endl;
}
cout<<endl<<"Want to
continue[Y/y]:";
cin>>ch1;
} while(ch1=='Y' || ch1=='y');
}
output:



1) Create a C++ function named insertNode to insert a new node with a given value...
using C++, NOT C language 1. Write a function called insert() to insert a node to the beginning of a linked list. The data is passed into the function. For example insert(8) will insert a node at the beginning of the list with the number 8 in the data field. Each node in the linked list is a ListNode struct as discussed in class. 2. Write a function called print() that will traverse the entire linked list and print out...
Write a function insertNode which inserts the given value into a new LLNode at the head of the given linked list. Updates the head of the linked list using a double pointer. Example call to insert 10 at the head of the linked list: insertNode( &pHead, 10 ); Complete the function below. void insertNode(LLNode **ppHead, int x){
[C++] Create three functions for a singly linked list: - Function 1: Insert a string into the linked list - Function 1: Insert a node after a given node (Node* curNodeptr, Node* newNodePtr) - Function 2: Delete the node passed to it by a pointer, it will take in the head and curPtr '(Node*, Node*)' struct Node{ string data; Node *next; };
Using C Please comment
Part 1: BST Create a link based Binary Search tree composed of a Node and a Tree struct. You should have a header file, BST.h, with the following: o Node struct containing left, right, and parent pointers, in addition to holding an Data struct value Tree struct containing a pointer to the root of the tree A function declaration for a function that allocates a tree, and initializes the root to NULL o o o A...
CODE IN C++ Given: typedef char ItemType; // a struct type named NodeType that includes a ItemType and pointer // (to a NodeType) field struct NodeType { ItemType value; NodeType * next; }; bool Delete (NodeType * & firstPtr, ItemType value) { NodeType * prev, * cur; cur = Search (firstPtr, value, prev); if (cur==NULL) return false; else { // remove cur node from the linked list if (prev!=NULL) { //not the first one prev->next = cur->next;...
linked list operation
/***************************************************************************************
This function creates a new node with the information give as a parameter and looks
for the right place to insert it in order to keep the list organized
****************************************************************************************/
void insertNode(string first_name, string last_name, string phoneNumber)
{
ContactNode *newNode;
ContactNode *nodePtr;
ContactNode *previousNode = nullptr;
newNode = new ContactNode;
/***** assign new contact info to the new node here *****/
if (!head) // head points to nullptr meaning list is empty
{
head = newNode;...
***In C Programming*** TASK 1: Complete itinerary.h Create a struct Destination that represents a node in a liked list. It contains the three letter airport code and a pointer to the next node int the linked list. You will need to write this struct. This file also includes the prototypes. They have all been written for you. There is no need to add the function comments for the prototypes. TASK 2: Write all functions in itinerary.c Write the following functions, which...
IN C Programming #include<stdio.h> #include<stdlib.h> typedef struct nodestruct { int item; struct nodestruct *next; } Node; typedef struct { int size; // Number of items on user’s list Node *head, *tail; } List; //In addition to creating an empty list, this function will also create two dummy nodes; one for the head, and the other for the tail. List* createList(); //This function creates a node containing the provided item, then inserts it into the list pointed by the provided list...
16 and 18 C++
11. Given the dynamic linked implementation of a linked list shown below, write expressions that do the following, assuming that currPtr is somewhere in the middle of the list: a. Access the component member of the first list element. b. Advance currPtr to point to the next element. c. Access the component member of the next element (the one that follows the current element). d. Access the component member of the element that follows the next...
Input the data for node 1 1 Enter more yes/Kno ? n Display Insert First Insert Last Insert Anywhere Delete First Delete Last Delete Anyone Search Exit Enter your Choice 1 1) 2> 3> 4X 5> 6) 7> 8) Data at 1 1 - Instructions: 1. Write a program to manage following operations Dynamic link list using C language: on a Display List a. Make sure to declare Link List Start pointer inside the main function and pass the same...