Assignment Set 5 (Uploaded on September 16, 2015) Clarification deadline date: September 24, 2015 Submission deadline date: September 28, 2015 [Total Marks: 150 {Problem 1} + 120 {Problem 2} + 30 {Makefile} = 300] ------------------------------------------------------------------------- Problem 1: Write a C program that creates a singly linked list using self referential structures with the following functionalities: (a) add a node at the beginning of the link list; [10] (b) add a node at the end of the link list; [15] (c) ask from the user at which position the node is to be added, and if possible, add the node at the requisite location; [15] (d) delete a node from the beginning of the link list; [10] (e) delete a node from the end of the link list; [15] (f) ask from the user the position of the node to be deleted, and if possible, delete the node from the requisite location; [15] (g) prints the linked list [10]. Once the linked list is created, simulate the to-and-fro random walk on the linked list using link reversal techniques discussed in the class. The random walk can be implemented by generating a random number between [0,1] and traversing forward (backward) if the number generated is less (greater) than 0.5. Keep provisions of printing the linked list, whenever the user wants. [40] [Marks: 90{(a) to (g)} + 40 + 20 {Good programming habits} = 150] ------------------------------------------------------------------------- Problem 2: This problem is about detecting loops, if it exists, in a singly linked list. For that, you have to create such a linked list and then detect the loop, if it exists. Write a C program that creates a singly linked list using self referential structures with the following functionalities: (a) add a node at the end of the link list; randomly decide whether the self-referential link points to NULL or points back to a node of the already created linked list, pick this node also randomly. [45] (b) prints the linked list [10]. (c) find out if the singly linked list has a loop and if the loop exists, find out the position of the node from the head of the singly linked list. [45] [Marks: 45 + 10 + 45 + 20 {Good programming habits} = 120] ------------------------------------------------------------------------- [Make your program multifile and write a proper makefile to compile your program. Name your makefile as make15xx, where xx is your roll number. Your makefile should be such that we can automatically run your makefile with the make command.] [Marks: 30 {Makefile}] ------------------------------------------------------------------------- Naming conventions for program files. xx is your roll number: For Problem 1: The name of the src file for problem 1 of assignment 5 should be ``cs15xx-assign5-src-prog1.c''. The name of the app file for problem 1 of assignment 5 should be ``cs15xx-assign5-prog1.c''. The name of the include file for problem 1 of assignment 5 should be ``cs15xx-assign5-prog1.h''. For Problem 2: The name of the src file for problem 2 of assignment 5 should be ``cs15xx-assign5-src-prog2.c''. The name of the app file for problem 2 of assignment 5 should be ``cs15xx-assign5-prog2.c''. The name of the include file for problem 2 of assignment 5 should be ``cs15xx-assign5-prog2.h''. ----------------------------------------------------------------------- At the top of each of your program files, add the following. If you are writing multi-file programs, then each file should have it. /*------------------------------------------------------------------ Name: Roll Number: Date of Submission: Deadline date: Program description: Acknowledgements: --------------------------------------------------------------------*/