Professional Documents
Culture Documents
Circular LLST
Circular LLST
void beginsert()
2. {
4. int item;
6. if(ptr == NULL)
7. {
8. printf("\nOVERFLOW");
9. }
10. else
11. {
13. scanf("%d",&item);
16. {
19. }
20. else
21. {
28. }
30. }
31.
32. }
1.
void lastinsert()
2. {
4. int item;
6. if(ptr == NULL)
7. {
8. printf("\nOVERFLOW\n");
9. }
10. else
11. {
13. scanf("%d",&item);
16. {
19. }
20. else
21. {
24. {
26. }
29. }
30.
32. }
33.
1.
void begin_delete()
2. {
3. struct node *ptr;
4. if(head == NULL)
5. {
6. printf("\nUNDERFLOW");
7. }
8. else if(head->next == head)
9. {
10. head = NULL;
11. free(head);
12. printf("\nnode deleted\n");
13. }
14.
15. else
16. { ptr = head;
17. while(ptr -> next != head)
18. ptr = ptr -> next;
19. ptr->next = head->next;
20. free(head);
21. head = ptr->next;
22. printf("\nnode deleted\n");
23.
24. }
1.
void last_delete()
2. {
3. struct node *ptr, *preptr;
4. if(head==NULL)
5. {
6. printf("\nUNDERFLOW");
7. }
8. else if (head ->next == head)
9. {
10. head = NULL;
11. free(head);
12. printf("\nnode deleted\n");
13.
14. }
15. else
16. {
17. ptr = head;
18. while(ptr ->next != head)
19. {
20. preptr=ptr;
21. ptr = ptr->next;
22. }
23. preptr->next = ptr -> next;
24. free(ptr);
25. printf("\nnode deleted\n");
26.
27. }
28. }
1.
void display()
2. {
3. struct node *ptr;
4. ptr=head;
5. if(head == NULL)
6. {
7. printf("\nnothing to print");
8. }
9. else
10. {
11. printf("\n printing values ... \n");
12.
13. while(ptr -> next != head)
14. {
15.
16. printf("%d\n", ptr -> data);
17. ptr = ptr -> next;
18. }
19. printf("%d\n", ptr -> data);
20. }