preview

Csci 311 Unit 5

Decent Essays

/*Program Name: Menu Driven Doubly linked list Name: Akshay Prakash Joshi Course number: CSCI 311 Project Description: This program is for menu driven doubly linked list. The menu has various options to select from, the program uses different function calls to do the specific task. It has a node structure which contains integer data, pointers for next node and previous node of doubly linked list. It has a Head node initialing pointing towards NULL, and uses two temporary pointer nodes *n and *temp1 for performing various functions. The functions performed are adding node front and back of the list, deleteing node at the front and back, printing nodes, counting and checking weather the list is empty or not. Initials Date Change and Fix log AJ …show more content…

printing(); } /* The add back node function adds link at back of list. In this function a new node n is used and data is taken into data part of n. Condition for whether Head is empty or not is checked. If Head is NULL then N is copied to Head. When Head is not pointing to NULL temp1 pointer is used which copies head and sets previous pointer value to NULL, next to temp1 and temp1 previous to null , where data from n is given to head and then list is displayed. */ void DoubleLinkedListAddBackNode() // Function for adding node back { cout << "enter data to be stored" << endl; // Print information. cin >> n->data; // Get the data in data part of n node. if (Head == NULL) // If head is NULL copy data from n to { Head = n; // to Head and set pointers n->next = NULL; // next and previous to NULL. n->prev = NULL; } else { temp1 = Head; // else get temp1 copies head n->next = temp1; // sets next of n to

Get Access