Build a singly linked list with 10 noes. The data are "This is my first project in Data structure and algorithm". First node is "This" second "is" and so on. Build insert function, insert "the " before "Data" and delete function, delete "my" before "first". Search "in" and output it location and then append "C++" and output the linked list again. In writing this program use menu which includes ”1. Create; 2. Insert; 3. Delete; 4. Append; 5. Search; 6. Quit”.
Screenshot of code:


output:




code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node
{
string s;
node* next;
};
node* create(string str)
{
node* t=new node;
t->s=str;
t->next=NULL;
return t;
}
node* append(node* head,string str)
{
node* h=head;
if(h==NULL)
return create(str);
while(h->next!=NULL)
h=h->next;
h->next=create(str);
return head;
}
node* insert(node* head,string str,string tar)
{
node* h=head;
if(h->s==tar)
{
node* t=create(str);
t->next=h;
return t;
}
while(h->next->s!=tar)
h=h->next;
node* t=create(str);
node* tmp=h->next;
h->next=t;
t->next=tmp;
return head;
}
node* del(node* head,string str,string tar)
{
node* h=head;
if(h->s==str&&h->next->s==tar)
{
node* t=h->next;
free(head);
return t;
}
while((h->next->s!=str)||(h->next->next->s!=tar))
h=h->next;
node* t=h->next;
h->next=h->next->next;
free(t);
return head;
}
ll search(node* head,string str)
{
ll c=1;
node* h=head;
while(h!=NULL&&h->s!=str){
h=h->next;
c++;}
return c;
}
void dis(node* head)
{
node* h=head;
while(h!=NULL)
{
cout<<h->s<<" ";
h=h->next;
}
cout<<"\n";
}
int main()
{
ll ch;
string str,s1;
node* head=NULL;
while(1)
{
cout<<"Enter 1:to create\n 2:to insert\n 3:to Delete\n 4:to
append\n 5:to Search\n 6:to Quuit\n 7: to display list\n";
cin>>ch;
if(ch==1)
{
cout<<"Enter string: ";
cin>>str;
create(str);
}
else if(ch==2)
{
cout<<"Enter source and destination string: ";
cin>>str>>s1;
head=insert(head,str,s1);
}
else if(ch==3)
{
cout<<"Enter source and destination string: ";
cin>>str>>s1;
head=del(head,str,s1);
}
else if(ch==4)
{
cout<<"Enter string: ";
cin>>str;
head=append(head,str);
}
else if(ch==5)
{
cout<<"Enter string :";
cin>>str;
ll indx=search(head,str);
cout<<str<<" is present at position
"<<indx<<endl;
}
else if(ch==7)
dis(head);
else
break;
}
}
//please upvote.
Build a singly linked list with 10 noes. The data are "This is my first project...
build a singly linked list in C++, input data from keyboard, this list includes 10 nodes. The data are "This is my first project in Data Structure and algorithm", the first node is is "This", second "is" and so on.
[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; };
Exercise-1:15 points Develop a node class and a singly list class. The node class should have two state variables namely data and nextNode. The singly list class should contain the following methods . Middlelnsert-insert a node somewhere in the middle of the list . Startinsert-insert a node at start of the Linked list Endinsert-insert a node at the end of the Linked list . Delete-delete a node Traverse-prints all the node's data Reverse -reverses the linked list Note: Choose appropriate...
Write a Python function to implement the quick sort algorithm over a singly linked list. The input of your function should be a reference pointing to the first node of a linked list, and the output of your function should also be a reference to the first node of a linked list, in which the data have been sorted into the ascending order. (You may use the LinkedQueue class we introduced in the lecture directly in your program.)
how to implement a linked list object using only singly linked list toolkit. Then implement a FREQUENCY function to count the ovcurrence of each element in the list. task#1: Add = operator to node: implement the assignment operator for the node such that setting a node = overwrites the value in the node with the value. task#2:Linked List class implement the methods of linked list. insert search and locate remove node* operator [] task#3: Implement the Frequency
Please use C++
CS3358 Insert and delete a node Programming Project 2: The linked list - Reference: chapter 18: Create an array of 15 student records that should not be sorted Create a liked list of 15 student record nodes. Each node is a node of one student record from the above unsorted array. The list of student records should be sorted by student ID. (Insert function without sort function to create a linked list.) (If you insert correctly, the...
Create a linked list of at least 15 different values that are prompted for and entered while the program is running. Appending a node attaches that node to the end of the list while inserting a node places it in order maintaining a sorted list. Create a menu driven program where you have the options to appended, insert, display, and delete a node. Display the list after first appending data showing it in no specific order, delete all nodes and...
Answer all questions
1- in circular singly linked list, previous pointer of the first node points to which node A. First node B. Itself C. null D. Last node 2- Which of the following is NOT an applications of linked lists? A. Implementation of stacks and queues B. Dynamic memory allocation C. Manipulation of polynomials D. Keeping people at home during epidemics like corona virus 3- In a circular singly linked list? A. Components are all linked together in some...
Build a double linked list to accommodate the following numbers: 6,3,2,1,5, 0 in C Programming language A. Print list forward B. Sort the list C. Delete a node with 3 D Print the list backwards E. Insert a node with 10 between the first and the second nodes
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...