Consider the the same C source file (sltcll.c). a) Write the delete and update functions, either in C programming langua

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Consider the the same C source file (sltcll.c). a) Write the delete and update functions, either in C programming langua

Post by answerhappygod »

Consider The The Same C Source File Sltcll C A Write The Delete And Update Functions Either In C Programming Langua 1
Consider The The Same C Source File Sltcll C A Write The Delete And Update Functions Either In C Programming Langua 1 (67.74 KiB) Viewed 51 times
Consider The The Same C Source File Sltcll C A Write The Delete And Update Functions Either In C Programming Langua 2
Consider The The Same C Source File Sltcll C A Write The Delete And Update Functions Either In C Programming Langua 2 (140.33 KiB) Viewed 51 times
consider the both photos
Consider the the same C source file (sltcll.c). a) Write the delete and update functions, either in C programming language or using Pseudo code. b) Modify the insert function to insert an item anywhere in the linked list, without compromising the existing order (i.e. sequence) of nodes.
18:57 # TI #include //this pre-processor directive is required for malloc struct node { int data; struct node* link; //create the node user-defined data structure }; //function prototpe for inserting a new node to the linked list struct node* insert(int d, struct node* h); int main() { //function prototpe for displaying the linked list void displayLL (struct node* h); linked list struct node* head=NULL; } //create the head pointer of the //call insert to add a node to the linked list * * * * head-insert (12, head); head=insert(23, head); head-insert (21, head); insert (-3, head); insert(123, head); insert (-23, head); 2 | ... 100% | return 0; //display the linked list displayLL (head); struct node* insert(int d, struct node* h) { //create a pointer variable to loop through the linked list struct node* loop=NULL; //create a pointer variable to keep the end node linked list struct node* prev=NULL; //create new pointer to point to a "new block" of memory that can hold a struct node struct node* new-malloc(sizeof(struct node)); //set data and the link (*new).data=d; //printf("\nnew's data: %d\n", (*new).data); (*new).link=NULL; //printf("\nnew's link: %p\n", (*new).link); //check for head node (=if there are no nodes in the list) if (h==NULL) { data: %d\n", (*head).data); printf("\nhead's link: %p\n", (*head).link); }else{ list to find the tail end loop=h; } h=new; //printf("\nhead's //step to next node } //loop through the linked while(loop!=NULL) { } return h; printf("\n"); //copy the new node's memory address to end (=tail) node's link. (*prev).link=new; prev=loop; loop=(*loop).link; } void displayLL (struct node* h) { //create a pointer variable to loop through the linked list struct node* loop=NULL; loop=h; while(loop!=NULL) { printf(" %d ", (*loop).data); 1 printf(" %p |-->", (*loop).link); loop=(*loop).link;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply