WINSEM2012-13_CP0824_28-Mar-2013_RM02_Winter-2012-13-dsa-programs2.pdf - C PROGRAMS ON LINEAR SINGLY LINKED LIST LINKED STACK and LINKED QUEUE 1 Write a

WINSEM2012-13_CP0824_28-Mar-2013_RM02_Winter-2012-13-dsa-programs2.pdf

This preview shows page 1 - 3 out of 10 pages.

Page 1 ‘C’ PROGRAMS ON LINEAR SINGLY LINKED LIST, LINKED STACK , and LINKED QUEUE 1) Write a ‘C’ program to implement linear singly linked list Soln)
Image of page 1
M.NAGARAJU, SCSE, VIT Page 2 case 6:printf("Enter regno of key node\n");scanf("%d",&sno); del_after(head,sno); break; case 7:del_last(head);break; case 8:display(head);break; case 9:printf("Enter regno to be searched\n"); scanf("%d",&sno); search(head,sno); break; case 10:c=count(head); printf("Number of elements in the list is %d\n",c); break; case 11:exit(1); default:printf("Wrong choice\n"); } } getch(); } void create(node *list) { printf("Enter student regno\n"); printf("Type -999 to stop creation\n"); scanf("%d",&list->regno); /* Read student regno */ printf("Enter student name\n"); printf("Type sss to stop creation\n"); scanf("%s",list->name); /* Read student name */ if(list->regno == -999) { list->next=NULL; /* Terminal or Sentinel node */ } else { list->next=(node *)malloc(sizeof(node)); /* Space for next node */ create(list->next); /* Recursive call */ } }
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 10 pages?

  • Spring '19
  • Articles with example C code, sentinel value

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture