Posts

Showing posts with the label Implement singly linked list operations

Singly Linked List program #3

Image
25. Write a menu driven program to implement following operations on the singly linked list. i. Insert a node at the end of the linked list. ii. Delete a first node of the linked list. iii. Delete a last node of the linked list. iv. Delete a node from specified position. #include<stdio.h> #include<stdlib.h> struct node {      int info;      struct node * link; }; typedef struct node Node; Node * insert_at_last(int x); Node * delete_from_first(); Node * delete_from_last(); Node * delete_from_specified(int p); void display(); Node * first; int a,count=0; void main() {      int x,ch,p;      printf ("SINGLY LINKED LIST OPERATIONS\n");      while (1)      {         printf ("------------------------------------------\n");         printf ("      1    -...

Singly Linked List program #2

Image
24. Write a menu driven program to implement following operations on the singly linked list. i. Insert a node at the front of the linked list. ii. Display all nodes. #include<stdio.h> #include<stdlib.h> struct node {      int info;      struct node * link; }; typedef struct node Node; Node * insert_at_first(int x); void display(); Node * first='\0'; void main() {      int x,ch;          printf ("SINGLY LINKED LIST OPERATIONS\n");      while (1)      {         printf ("------------------------------------------\n");         printf ("      1    -->    INSERT AT FIRST              \n");         pri...