Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, can someone please help me with this project? Thanks! In this project, yo

ID: 441465 • Letter: H

Question

Hello, can someone please help me with this project? Thanks!

In this project, your task is to construct and maintain a linked list where each cell contains a search key associated with a nonnegative integer value. The program must work iteratively with the user and perform the operations specified by the user. Your program must support three different types of operations including Insertion, Deletion and Search. Insertion requires your program to insert a specified search key and its associated integer to the linked list. If the search key is not found in the linked list, the program must generate a new cell on the heed of the linked list to store the search key and the integer, otherwise, the integer associated with the search key is replaced by the one specified by the user. The Deletion operation removes the cell that contains the search key provided by the user from the linked list and does nothing if none of the cells contain the search key value. When subject to the Search operation, the linked list must be exhaustively traversed to look for the cell with the provided search key and output the associated integer. In addition, your program also needs to locate the preceding cell with a distance of the obtained integer to the cell that contains the key specified by the user and output its search key (see Ch. 3.4 in the textbook and exercise 12). No duplicate search keys are allowed in the linked list. In other words, when insertion is performed, the linked list must be searched to ensure that the inserted search key does NOT exist in the linked list before a new cell is generated. Input format The input format for different operations are specified as follows: Insertion operation: I [Search key] [Integer] Deletion operation: D [Search key] Search operation: S [Search key] Implementation You are required to implement a class to generate and manipulate the linked list. Operations must be implemented with different functions in the class, and you are required to implement the Search operation with either one of the following approaches discussed in the class: Two pointers that move only forward in the list (similar to algorithm 3.9 in the textbook) A "zig-zag" scan with a stack of pointers You may assume that the search key is of string type. You may choose to implement any of the above two algorithms for your search and must mention which one you picked in your Readme file. Your program will be tested and graded based on the performance on the following input files, full credit will be given if your program is written in a good style and works perfectly well on them. nput1.txt Input2.txt Input3.txt Explanation for the first search: element7 is at the head of the linked list, going back 2 positions from there is not possible. Therefore we only print the associated integer. Explanation for the second search: element1 is located as the third node and it is associated with integer 1, going back 1 node from element1 returns element2. We print element1 s associated integer and the key of the previous node: element2.

Explanation / Answer

Please rate me as 5 star rating #include struct node //Each node in list will contain data and next pointer { int data; struct node *next; }; struct node *start; void insertbeg(void) { struct node *nn; int a; nn=(struct node *)malloc(sizeof(struct node)); printf("enter data:"); scanf("%d",&nn-;>data); a=nn->data; if(start==NULL) //checking if List is empty { nn->next=NULL; start=nn; } else { nn->next=start; start=nn; } printf("%d succ. inserted ",a); return; } void insertend(void) { struct node *nn,*lp; int b; nn=(struct node *)malloc(sizeof(struct node)); printf("enter data:"); scanf("%d",&nn-;>data); b=nn->data; if(start==NULL) { nn->next=NULL; start=nn; } else { lp=start; while(lp->next!=NULL) { lp=lp->next; } lp->next=nn; nn->next=NULL; } printf("%d is succ. inserted ",b); return; } void insertmid(void) { struct node *nn,*temp,*ptemp; int x,v; nn=(struct node *)malloc(sizeof(struct node)); if(start==NULL) { printf("sll is empty "); return; } printf("enter data before which no. is to be inserted: "); scanf("%d",&x;); if(x==start->data) { insertbeg(); return; } ptemp=start; temp=start->next; while(temp!=NULL&&temp-;>data!=x) { ptemp=temp; temp=temp->next; } if(temp==NULL) { printf("%d data does not exist ",x); } else { printf("enter data:"); scanf("%d",&nn-;>data); v=nn->data; ptemp->next=nn; nn->next=temp; printf("%d succ. inserted ",v); } return; } void deletion(void) { struct node *pt,*t; int x; if(start==NULL) { printf("sll is empty "); return; } printf("enter data to be deleted:"); scanf("%d",&x;); if(x==start->data) { t=start; start=start->next; free(t); printf("%d is succ. deleted ",x); return; } pt=start; t=start->next; while(t!=NULL&&t-;>data!=x) { pt=t;t=t->next; } if(t==NULL) { printf("%d does not exist ",x); return; } else { pt->next=t->next; } printf("%d is succ. deleted ",x); free(t); return; } void display(void) { struct node *temp; if(start==NULL) { printf("sll is empty "); return; } printf("elements are: "); temp=start; while(temp!=NULL) { printf("%d ",temp->data); temp=temp->next; } return; } void main() { int c,a; start=NULL; do { printf("1:insert 2:delete 3:display 4:exit enter choice:"); scanf("%d",&c;); switch(c) { case 1: printf("1:insertbeg 2:insert end 3:insert mid enter choice:"); scanf("%d",&a;); switch(a) { case 1:insertbeg();break; case 2:insertend(); break; case 3:insertmid(); break; } break; case 2:deletion(); break; case 3:display(); break; case 4: printf("program ends "); break; default:printf("wrong choice "); break; } } while(c!=4) ; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote