





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
Write a title that briefly explains what it is about. Between 20 and 90 charactersWrite a title that briefly explains what it is about. Between 20 and 90 charactersWrite a title that briefly explains what it is about. Between 20 and 90 charactersWrite a title that briefly explains what it is about. Between 20 and 90 characters
Typology: Summaries
1 / 9
This page cannot be seen from the preview
Don't miss anything!
// C program to implement Linked List operations #include <stdio.h> #include <stdlib.h> struct node { int data; struct node *nextPtr; }; typedef struct node Node; typedef Node *NodePtr; /*************
void merge(NodePtr list1, NodePtr list2, NodePtr *l3StartPtr, NodePtr *l3EndPtr); // Check if the list is empty (Already developed) int isEmpty(NodePtr sPtr); // Print out the list (Already developed) void printList(NodePtr sPtr); // Selection menu (Already developed) void menu(void); int main() { // Two pointers for the beginning and ending of the linked list generated. NodePtr startPtr = NULL; NodePtr endPtr = NULL; // Three pairs of pointers for beginning and ending of the three linked lists used in the merge selection NodePtr l1StartPtr = NULL; NodePtr l1EndPtr = NULL; NodePtr l2StartPtr = NULL; NodePtr l2EndPtr = NULL; NodePtr l3StartPtr = NULL; NodePtr l3EndPtr = NULL; int item; menu(); unsigned int choice; scanf("%u", &choice); while (choice != 6) { switch (choice) { case 1: /*************
break; case 5: /*************
return 0; } // display menu to the user (Already developed) void menu(void) { puts("Enter your choice:\n" " 1 to add a new element to the beginning of the list.\n" " 2 to add a new element to the end of the list.\n" " 3 to print the list in the reverse order.\n" " 4 to reverse the list, in-place.\n" " 5 to merge two ordered lists into a new ordered list.\n" " 6 to end."); printf("%s", "? "); } // return 1 if the list is empty, 0 otherwise (Already developed) int isEmpty(NodePtr sPtr) { return sPtr == NULL; } // print the list from the beginning (Already developed) void printList(NodePtr sPtr) { if (isEmpty(sPtr)) puts("List is empty.\n"); else { puts("The list is:"); while (sPtr != NULL) { printf("%d --> ", sPtr->data); sPtr = sPtr->nextPtr; } puts("NULL\n"); } } /*************
printReverseList(sPtr->nextPtr); // call printReverseList with next pointer of sPtr printf("%d --> ",sPtr->data); // display sPtr } } /*************
free(temp); // delete temp } // set start and end pointer to null *ePtr = NULL; *sPtr = NULL; } /*************