Posts

Featured Post

Ordered Singly Linked List program #1

Image
26. Write a menu driven program to implement following operations on the ordered singly linked list. i. Insert a node such that linked list is in ascending order. (According to info. field) 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_in_order(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");     ...

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...

Singly Linked List program #1

Image
23. Implement a program to create a node for singly linked list. Read the data for a node, print the node and release the memory of the node. #include<stdio.h> #include<stdlib.h> struct node {      int info;      struct node * link; }; // typeded struct node Node means using struct node replace with Node bellow void main() {      int x;      struct node * new;      new=(struct node * )malloc(sizeof(struct node));      if(new=='\0')      {           printf("Memory is not available\n");           return;      }      else      {           printf("Enter data which you want to add\n");       ...

Queue program #2

Image
22. Implement Circular Queue using array that performs following operations: INSERT, DELETE,DISPLAY. #include<stdio.h> #define N 5 int q[N]; int f=-1; int r=-1; void cqinsert(int y); int cqdelete(); void display(); void main() {      int ch,x,a;     printf ("QUEUE OPERATION\n");     while (1)     {         printf ("------------------------------------------\n");         printf ("      1    -->    INSERT               \n");         printf ("      2    -->    DELETE               \n");         printf ("...