


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
you should take a look and study
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!
1. (30 p) Explain briefly what the following functions that use the node structure below do. struct node { int data; struct node* next; }; (a) void function1(struct node** a, struct node** b) { struct node* cur; if (a == NULL) { a = b; } else { cur = a; while (cur - >next != NULL) { cur = cur - >next; } cur - >next = b; } b=NULL; } (b) static void function2(struct node head) { struct node r = NULL; struct node cur = head; struct node n; while (cur!= NULL) { n = cur - >next; cur - >next = r; r = cur; cur = n; } head = r; } (c) void function 3 (struct node head) { struct node cur = head; if (cur == NULL) return; while(cur - >next!=NULL) { if (cur - >data == cur - >next->data) { struct node nextNext = cur - >next->next; free(cur - >next); cur - >next = nextNext; } else { cur = cur - >next; } } }
3. (35 p) Define a node structure for the structure given below. struct node{ ... }; Write a complete C program that you will create the connections between nodes. You can assign, 1 to the value of the 1st element, 2 to the value of the 2nd element, n to the value if the nth element. Assume that the value n is user-entered in your program.