-
Notifications
You must be signed in to change notification settings - Fork 0
/
circularLinkedList.c
57 lines (54 loc) · 2.05 KB
/
circularLinkedList.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
#include "circularLinkedList.h"
int main(void)
{
NODEPTR list,list2;
int choice, data, target, flag;
initList(&list); // function call to initialize list
createList(&list); // function call to create list
do
{
printf("\n1.Display\n2.Count Nodes\n3.Concatinate Lists\n4.Insert First\n5.Insert Last\n6.Insert WRT Information\n");
printf("7.Delete First\n8.Delete Last\n9.Delete WRT Information\n10.Exit\nEnter choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1: displayList(list); // function call to display list
break;
case 2: printf("\nThere are %d node(s) in the list.\n",countNode(list)); // function call to count number of nodes in a list
break;
case 3: initList(&list2); // function call to initialize list
createList(&list2); // function call to create list
concatList(&list,&list2); // function call to concatinate list
break;
case 4: printf("\nEnter information...\n");
scanf("%d",&data);
insertFirst(&list,data); // function call to insert a node at the begining
break;
case 5: printf("\nEnter information...\n");
scanf("%d",&data);
insertLast(&list,data); // function call to insert a node at the end
break;
case 6: printf("\nEnter target...\n");
scanf("%d",&target);
printf("\nEnter data...\n");
scanf("%d",&data);
insertAfterInfo(&list,target,data); // function call to insert node(s) at the end of all the occurences of a given target
break;
case 7: deleteFirst(&list); // function call to delete the first node
break;
case 8: deleteLast(&list); // function call delete the last node
break;
case 9: printf("\nEnter information...\n");
scanf("%d",&target);
printf("\n%d deletion(s) made.\n",deleteInfo(&list,target)); // function call to delete all occurences of target
break;
case 10: printf("\nDONE!\n");
break;
default: printf("\n Invalid choice. Re-enter please...\n");
}
}
while(choice!=10);
return 0;
}