1 1. Write a program to perform the insert operation on a singly linked list. a) At beginning b) At middle c) At end Program:#include<stdio.

h> #include<stdlib.h> #include<alloc.h> #include<conio.h> typedef struct node { int data; struct node *next; }node; void createlist(); void showlist(); void insertbeg(); void insertend(); void insertafter(); node *start=NULL; int n, pos; void main() { int c; clrscr(); while(1) { printf("\n------Menu-----\n"); printf("1.Create List\n 2. Insert List\n 3.Insert After\n 4.Insert End\n 5.Display\n 6.Exit\n"); printf("Enter your choice\n"); scanf("%d",&c); switch(c) { case 1:printf("Enter Domain\n"); scanf("%d",&n); createlist(); break; case 2: printf("Enter Data to be inserted\n"); scanf("%d",&n); insertbeg(); break;

2 case 3:printf("Enter postion of data\n"); scanf("%d",&pos); insertafter(); break; case 4:printf("Enter Data\n"); scanf("%d",&n); insertend(); break; case 5:printf("Created linked list\n"); showlist(); break; case 6:exit(0); break; default:printf("Wrong entry\n"); } getch(); }} void createlist() { node *temp; if(start==NULL) { start=(node*)malloc(sizeof(node)); start->data=n; start->next=NULL; } else { temp = start; while(temp->next!=NULL) temp=temp->next; temp->next=(node*)malloc(sizeof(node)); temp->next->data=n; temp->next->next=NULL; }} void insertbeg() {node *temp; temp=(node*)malloc(sizeof(node)); temp->data=n; temp->next=start; start=temp; }

3 void insertafter() { node *temp; node *s=start; int i; for(i=1;i<pos;i++) {s=s->next; if(s==NULL) {printf("Insertion not possible\n"); getch(); return; }} temp=(node*)malloc(sizeof(node)); temp->data=n; temp->next=s->next; s->next=temp; } void insertend() { node *temp; temp=start; while(temp->next!=NULL) temp=temp->next; temp->next=(node*)malloc(sizeof(node)); temp->next->data=n; temp->next->next=NULL; } void showlist() { node*p; if(start==NULL) { printf("List Empty\n") ; getch(); return; } p=start; while(p!=NULL) { printf("%d\n",p->data); p=p->next; }}

4 Output:-

Remarks:-

We have used here the self refrencial structure to execute the singly linked list insert operation a) at beginning b) at middle c) at end In this we have defined different functions to perform each operation such as Create list, insert at beg,insert at end ,display and so on.

h> #include<stdlib.Delete beginning\n 2. delafter(). scanf("%d". default:printf("Wrong entry\n").h> #include<conio.h> #include<alloc.&pos). break. while(1) { printf("------Menu-----\n").h> typedef struct node { int data. case 4:exit(0). }node. struct node *next. void delbeg(). printf("1. node *start=NULL. a) At beginning b) At middle c) At end Program:#include<stdio.&c). switch(c) { case 1:delbeg(). pos. Write a program to perform the delete operation on a singly linked list.Exit\n"). void delafter().Delete end\n 3.5 2. scanf("%d". printf("Enter your choice\n"). case 2:delend(). void main() { int c. int n.Delete After\n 4. break. void delend(). } . break. break. case 3:printf("Enter postion of data\n").

} void delend() { node *temp. }} void delbeg() {node *temp. free(temp). node *s=start. }} temp=s->next. int i. free(temp). while(s->next->next!=NULL) s=s->next. start=start->next. } void delafter() { node *temp. return. for(i=1. getch(). if(s==NULL) {printf("node not sufficient\n"). temp->next=NULL. s->next=NULL. temp->next=NULL. node *s=start.6 getch(). temp=s->next. } .i<pos. free(temp).i++) {s=s->next. s->next=temp->next. temp=start.

delete from end .delete after any position . .7 Output:- Remarks:- We have used here the self refrencial structure to execute the singly linked list delete operation a) at beginning b) at middle c) at end In this we have defined different functions to perform each operation such as delete from beg.display and so on.

void main() { int x[20]. a) Linear search b) Binary search Program:#include<stdio.int ).p. printf("\nWHICH TYPE OF SEARCH YOU WANT ?\n1-BINARY SEARCH\n2-LINEAR SEARCH\n").j<n.p+1). .int . of elements"). x[j]=temp.i<n.int []. printf("Enter %d elements\n". scanf("%d". x[i]=x[j].j.h> #include<conio. switch(s) { case 1:printf("\t\tBINARY SEARCH\n").key.i<n. } printf("ENTERED NUMBERS IN ASCENDING ORDER\n"). for(i=0. clrscr(). printf("\nEnter the no. for(i=0.i.h> int linearsearch(int .i++) printf("%d\n".&key).key). p=binarysearch(x. for(i=0. Write a program to perform the search operation on a array using:-.i++) for(j=i+1.s.temp.key.x[i]).&n).i++) scanf("%d".n).j++) if(x[i]>x[j]) { temp=x[i].&s). scanf("%d".int ).n. scanf("%d".&x[i]).n. else printf("\n %d is found at location %d".i<n-1. int binarysearch(int []. printf("\nEnter the element to be searched"). if(p==-1) printf("\nThe search is unsuccessful").8 3.

else printf("\n %d is found at location %d". i=i+1.int n. } return(-1). while(k>=a[i]&&(i<n)) { if(k==a[i]) return(i). if(k==a[mid]) return(mid).n).key. } return(-1). while(lo<=hi) { mid=(lo+hi)/2.x.9 break. } . hi=n-1. lo=0.mid.hi.p+1).int k) { int lo. if(k<a[mid]) hi=mid-1. p=linearsearch(key. break. } } int binarysearch(int a[].int a[]. if(p==-1) printf("The search is unsuccessful"). } int linearsearch(int k. break.int n) { int i=0. case 2:("\t\tLINEAR search\n"). else lo=mid+1. default:printf("Wrong Choice entered").

. Match the item with the element at the mid position if the item to be found matches with the element at mid position mid is displayed and search is successful otherwise we find whether the element to be search is smaller or larger then element at mid if large then low = mid +1 else high = mid -1.10 Output:- Remarks:- In this program we have used two types of searching techniques to search an element in an array a) Linear search b) Binary search In linear search what we have done is traverse the whole array and each time we match the item to be searched with the element at that position if the item is found it is displayed with the position In binary search we sort the array first and then divide the array in two half .

n).n). } printf("\nEnter choice in which u want to sort"). break.n).int). void main() { int a[100]. scanf("%d".i<n. printf("\nEneter the elements\n").l.&ch).Bubble sort"). void quicksort(int [].int.&a[i]).h> #include<conio. printf("\n1. case 2: insertionsort(a. Write a program to perform the sorting operation on a array using:-. int). printf("\n3. a) Bubble sort b) Insertion sort c) Selection sort d) Quick sort Program:#include<stdio. clrscr(). void selectionsort(int []. printf("\n2.11 4. case 3: selectionsort(a.i++) { scanf("%d".i.l.Insertion sort"). .ch.Quick sort\n\n"). printf("Enter value of n:\n"). l=0.&n).int). break. void insertionsort(int [].int).n. scanf("\n%d". switch(ch) { case 1: bubblesort(a. for(i=0. break.n).h> void bubblesort(int []. break. printf("\n4. printf("\n-----------Menu---------").Selection sort"). case 4: quicksort(a.

a[i]). a[i]=a[loc].j<n-i-1. a[loc]=temp. } } if(loc!=i) { temp=a[i]. for(j=i+1.i++) { min=a[i]. loc=j.j++) { if(a[j]>a[j+1]) { temp=a[j].j.i<n. break.temp. } . getch().int n) { int min. } printf("\nSorted list is as follow").i. for(i=0. } void bubblesort(int a[]. min=a[0]. a[j]=a[j+1].i. for(i=0.loc. a[j+1]=temp.i<n.12 default:printf("\n Invalid Entry"). } } } } void selectionsort(int a[].i<=n.i++) { for(j=0.i++) printf("\n%d". loc=i. for(i=0.j++) { if(a[j]<min) { min=a[j].j.int n) { int temp.j<=n-1.

int l. . } if(low<=high) { temp=a[low]. high=h. j=k-1. a[low++]=a[high]. key=a[(low+high)/2].key. } } void quicksort(int a[].temp.k. } } while(low<=high). low=l.high.low.int n) { int j.k<=n-1.int h) { int temp. for(k=1. while((temp<a[j])&&(j>=0)) { a[j+1]=a[j].13 } } void insertionsort(int a[]. } while(key<a[high]) { high--. if(l<high) quicksort(a.l. a[high--]=temp. } a[j+1]=temp.high).k++) { temp=a[k]. do { while(key>a[low]) { low++. j=j-1.

.14 if(low<h) quicksort(a.h). } Output:- Remarks:- In this program we use a menu driven window to choose which sorting technology the user want to sort. a) Bubble sort b) Insertion sort c) Selection sort d) Quick sort Using the above we can sort all the elements in an array in ascending or in descending order.low.

} int parent(int i) { return(i/2).large. heapsort(x. Write a program to perform the following:a) Create a heap. int right(int).int ). for(i=0.15 5.temp.n).int i.i++) scanf("%d".r.n). l=left(i). b) Sort the element of a heap Program:#include<stdio. void heapsort(int [].h> int parent(int).&x[i]).&n). } int right(int i) { return(2*i+2). clrscr(). for(i=0.int ).i++) printf("%4d".i<n. int left(int).h> #include<conio.i. printf("The sorted array is \n ").int ).n. printf("\nEnter the numbers of numbers to be sorted:\t"). void heapify(int []. printf("\nEnter %d elements \n". } int left(int i) { return(2*i+1).x[i]). } void heapify(int a[]. scanf("%d". . void main() { int x[20].int n) { int l. void buildheap(int [].i<n.

16 r=right(i). a[i]=a[large]. heapify(a.i. buildheap(a. } void heapsort(int a[]. a[i]=temp. a[large]=temp.i--) heapify(a. if((l<=n-1)&&(a[l]>a[i])) large=l.n). heapify(a. else large=i.n).large.0.m).i>=0. m=n. } } . for(i=n-1. if((r<=n-1)&&(a[r]>a[large])) large=r. if(large!=i) { temp=a[i].m.i--) { temp=a[0].int n) { int i. for(i=(n-1)/2.int n) { int i.temp. } } void buildheap(int a[].i>=1. m=m-1. a[0]=a[i].n).

17 Output:- Remarks:- .

Write a program to perform the Tower of Hanoi problem using recursion. CENTER. clrscr(). printf("\nSOLUTION \n\t (L=Left.h> void tower_of_hanoi(int n. Program:#include<stdio.'R'. } Output:- .C=Ceter)\n"). char CENTER) { if(n>0) { tower_of_hanoi(n-1. n. LEFT. printf("\n\tMove disk %d from %c to %c". char RIGHT. RIGHT). LEFT. LEFT). tower_of_hanoi(n.&n). CENTER. RIGHT. printf("\nEnter no. scanf("%d".'C').18 6. of disks: "). char LEFT.'L'. } } void main() { int n. tower_of_hanoi(n-1. RIGHT).h> #include<conio.R=Right.

printf("3. while(1) { printf("1. . printf("4. switch(choice) { case 1 :insert().Display\n"). Here we have use recursive function in order to perform the operation .break. int rear = -1.Insert\n"). scanf("%d". int display().h> # include<stdlib.h> # define MAX 5 void insert().&choice). printf("Enter your choice : "). printf("2. ~~~~~~~~*~~~~~~~~*~~~~~~~~~~~ 7. main() { int choice. void del().Tower of Hanoi problem is used for disk transfer from one space to another . int front = -1. int cqueue_arr[MAX]. Write a program to perform the following operation on a circular queue using array.19 Remarks:- In this program we have use the tower of Hanoi problem .Quit\n").Delete\n"). a) Insert ( ) b) Delete ( ) c) Display ( ) Program:# include<stdio.

break. }}} void insert() { int added_item. printf("Input the element for insertion in queue : "). else front = front+1. case 4:exit(0). }/*End of insert()*/ void del() { if (front == -1) { printf("Queue Underflow\n"). return.break. if((front == 0 && rear == MAX-1) || (front == rear+1)) { printf("Queue Overflow \n"). default:printf("Wrong choice\n").cqueue_arr[front]). cqueue_arr[rear] = added_item .20 case 2 :del(). if(front == rear) /* queue has only one element */ {front = -1. rear = 0. }/*End of del() */ . } else if(front == MAX-1) front = 0. return . } printf("Element deleted from queue is : %d\n". case 3:display(). else rear = rear+1. } if (front == -1) /*If queue is empty */ { front = 0. } else if(rear == MAX-1)/*rear is at last position of queue */ rear = 0. scanf("%d". rear=-1. &added_item).

return 0. front_pos++. }}printf("\n"). while(front_pos <= rear_pos) {printf("%d ".cqueue_arr[front_pos]). } else {while(front_pos <= MAX-1) {printf("%d ". } front_pos = 0. } printf("Queue elements :\n"). front_pos++.cqueue_arr[front_pos]).21 int display() {int front_pos = front. if( front_pos <= rear_pos ) while(front_pos <= rear_pos) {printf("%d ". } Output:- .rear_pos = rear.cqueue_arr[front_pos]). front_pos++. if(front == -1) {printf("Queue is empty\n").

a) Insert ( ) b) Delete ( ) c) Display ( ) Program:#include<stdio.22 Remarks:- In this program we have used a structure containing array and two variable called rear and front in order to execute the different operation performed on queue such as insert . delete . void display(). display etc. void insathead(int). Write a program to perform the following operation on a circular queue using linked list. void insattail(int). struct node *next. . void delathead(). void insatpos(int. ``````````````*````````````*`````````````` 8. }node.h> #include<alloc. It is also called a FIFO (First in first out). void create(int).h> #include<stdlib. void delatpos(int).int). void delattail(). A queue is one is which we can enter elements only from rear of a array and delete element from front of an array.h> typedef struct node { int data. node *last=NULL.

&c).&n. fflush(stdin). break.&n). scanf("%d". printf("\nEnter your choice"). case 4: printf("Enter the elements u want to insert at tail: "). break. Press 3 to isert an element at head\n4. Press 6 to delete an element from head\n7. do { printf("MENU\n1. break.&n).&n). scanf("%d".c. Press 4 to insert an element at tail\n5. default: printf("Wrong choice").loc. case 5: printf("Enter the elements and position u want to insert: "). Press 2 to display the list\n3.&loc). break. char ch. scanf("%d%d". } printf("\nDo you want to conyinue(y/n)"). scanf("%d". case 2: printf("The elements of the linked list are: "). break. case 0: exit(1). scanf("%d". insathead(n). insattail(n). press 7 to delete an element from tail\n8. . switch(c) { case 1: printf("Enter the elements u want to insert: ").loc). Press 8 to delete an element from any position\n10. display(). create(n). case 3: printf("Enter the elements u want to insert at head: "). Press 1 to create circular linked list\n2. case 8: printf("Enter the position from wherte u want to delete the element:"). case 7: delattail(). Press 0 to Exit"). case 6: delathead(). delatpos(loc). break.23 void main() { int n. scanf("%d". break. break. Press 5 to insert an element at any position you want\n6. insatpos(n.&loc).

} . } } void insattail(int x) { node *temp. last->next=temp. temp->data=x. last->next=temp. last->next=temp.*temp. return. return. temp=(node *)malloc(sizeof(node)). last->next=temp. temp=(node *)malloc(sizeof(node)).t!=last. if(last==NULL) { last=temp.t=t->next). temp->data=x. return. }while(ch=='Y'||ch=='y'). } void create(int x) { node *t. temp->data=x.&ch). temp=(node *)malloc(sizeof(node)).24 scanf("%c". } } void insathead(int x) { node *temp. } else { for(t=last->next. } else { temp->next=last->next. if(last==NULL) { last=temp. last=temp. if(last==NULL) { last=temp. temp->next=last->next. last->next=temp.

last=temp.t=last->next. printf("%d". } void insatpos(int x.t=t->next) printf("%d\t".int loc) { node *temp.t->data). } */ if(t==last) { temp->next=last->next. if(loc==1) { if(last==NULL) { last=temp. last->next=temp. } . temp->data=x.*t. last=temp.25 else { temp->next=last->next.t=t->next). last->next=temp. return. last->next=temp.t!=last. return. } for(cp=1. return. return. temp=(node *)malloc(sizeof(node)). for(t=last->next.cp<loc-1&&t!=last.t->data). } } void display() { node *t. int cp. { /*if(cp<loc-1) { printf("Cant insert at this position"). } temp->next=last->next. last->next=temp.

t->next=temp. } for(cp=1. } x=last->next->data. } x=last->next->data. return. last=t. x=last->data.26 else { } } } void delathead() { int x.t->next!=last. if(cp<pos-1) temp->next=t->next.t=t->next). } void delatpos(int pos) { node *t. last->next=last->next->next. } void delattail() { node *t. } for(t=last->next. return. t->next=last->next. return. if(last==NULL) { printf("No item in the list"). int x. .t=last->next. last->next=last->next->next. if(pos==1) { if(last==NULL) { printf("No item in the list"). if(last==NULL) { printf("No item in the list").cp<pos-1&&t!=last.t=t->next). return. int cp.x.

} } Output:- . } if(t->next==last) { x=t->next->data.27 { printf("Out of range"). last=t. return. } else { x=t->next->data. t->next=last->next. return. t->next=t->next->next. return.

scanf("%d".For POP\n3. s. printf("Enter Your Choice: "). delete . int item[15].c. a) Push ( ) b) Pop ( ) c) Display ( ) Program:#include<stdlib. }.h> struct stack { int top. clrscr().top=-1.28 Remarks:- In this program we have used a self refrencial structure i. It is also called a FIFO (First in first out). struct stack s. void main() { int i.For EXIT").h> #include<stdio.For DISPLAY\n4.h> #include<conio. while(1) { printf("\t\tSTACK OPERATION\n"). using a linked list and two variable called rear and front in order to execute the different operation performed on queue such as insert . ``````````````*````````````*`````````````` 9. Write a program to perform the following operation on a stack using array.e. printf("1.&c). switch(c){ .For PUSH\n2. A queue is one is which we can enter elements only from rear of a array and delete element from front of an array. display etc.

s. for(i=s.s. break.top==-1) printf("Stack empty"). break. scanf("%d". break.item[i]). case 2:if(s. } } Output:- . else printf("the deleted item is %d". else { printf("Enter the no.item[s. case 4:exit(1). } getch().29 case 1:if(s. } break.top==14) printf("Overflow").i--) printf("%d\n". default:printf("Wrong choice entered").top.i>=0.item[++s.top--]). u want to enter").&s.top]). case 3:printf("stack elements are").

void push(int). void display(). Write a program to perform the following operation on a stack using linked list. typedef struct stack node. }.h> #include<stdlib. delete . a) Push ( ) b) Pop ( ) c) Display ( ) Program:#include<stdio. struct stack *next. A stack is one is which we can enter elements only from top of a array and delete element from top of the array only. void main() { int n. node *top=NULL. char ch. do { printf("\n*********MENU*************").h> struct stack { int data. display etc. `````````````*```````````*```````````` 10.30 Remarks:- In this program we have used an array and a variable called top in order to execute the different operation performed on stack such as insert . . void pop().c. It is also called a LIFO (Last in first out).

printf("\n4. top=temp. break. if(top==NULL) { top=temp. Pop"). switch(c) { case 1: printf("\nEnter the element: "). printf("\nEnter your choice: ").&ch). } else { temp->next=top. return. Push"). } void push(int x) { node *temp. scanf("%d". fflush(stdin).31 printf("\n1. return. int x. scanf("%d". printf("\n2. default: printf("Wrong Choice"). case 2: pop(). break. break.&c). } temp->data=x. scanf("%c". Display"). } while(ch=='Y'||ch=='y'). return. temp=(node *)malloc(sizeof(node)). Exit"). } printf("\nDo u want to continue?(y/n)"). case 3: display(). printf("\n3.&n). }} void pop() { node *t. push(n). . case 0: exit(0). if(temp==NULL) { printf("\nOverflow"). top->next=NULL.

} x=top->data.32 if(top==NULL) { printf("\nStack is Empty").t!=NULL. t=top.t=t->next) { printf("\t%d". free(t). return. top=top->next. for(t=top.t->data). } void display() { node *t. }} Output:- . return.

33 Remarks:- In this program we have used a link list and a variable called top in order to execute the different operation performed on stack such as insert . int top=-1. ````````````````*`````````````````*``````````````` 11. display etc. int prcd(char symbol) { switch(symbol) { case '+': case '-':return 2. case '^': case '$':return 6. Program:#include<stdio. break. It is also called a LIFO (Last in first out). case '(': case ')': case '#':return 1. break. void push(char item). Write a program to convert infix to postfix and evaluate using stack. char pop(). .h> #define MAX 20 char stack[MAX]. A stack is one is which we can enter elements only from top of a array and delete element from top of the array only. delete . break.h> #include<string. case '*': case '/':return 4.h> #include<conio.

} else{ if(prcd(symbol)>prcd(stack[top])) .i<strlen(infix). break.j=0. } pop().//pop out (. j++. for(i=0.i++) { symbol=infix[i]. j++. stack[++top]='#'. else if(symbol==')') { while(stack[top]!='(') { postfix[j]=pop(). } else{ if(symbol=='(') push(symbol). if(isoperator(symbol)==0) { postfix[j]=symbol.char postfix[]) { int i. default:return 0.34 break. } } void convertip(char infix[].symbol. } } int isoperator(char symbol) { switch(symbol) { case '+': case '-': case '*': case '/': case '^': case '$': case '(': case ')':return 1.

a=stack[top]. top--. } .postfix). else{ while(prcd(symbol)<=prcd(stack[top])) { postfix[j]=pop(). } void push(char item) { top++. puts(postfix). convertip(infix. } void main() { char infix[20]. }}}} while(stack[top]!='#') { postfix[j]=pop().//null terminate string.35 push(symbol). printf("The corresponding postfix string is:\n"). clrscr(). } push(symbol).postfix[20]. stack[top]=item. return a. j++. printf("Enter the valid infix string:\n"). getch(). gets(infix). } char pop() { char a. j++. } postfix[j]='\0'.

‘’’’’’’’’’’’*’’’’’’’’’’’’’’’*’’’’’’’’’’’’’’’’’’’ . operators are performed on two surrounded operands.called the infix form because in this expression. But in postfix expression operator is expressed after the two operands on which it is to be performed .36 Output:- Remarks:- In this program any expression that is in its normal form .

37 12. .h> #define MAXSIZE 50 int queue[MAXSIZE]. EXIT"). printf("\n1. a) Insert ( ) b) Delete ( ) c) Display ( ) Program:#include<stdio. void insert(int). case 3: display(). insert(n). DISPLAY"). break. printf("\nEnter your choice: "). do { printf("\n\n********MENU********"). clrscr(). void display(). Write a program to perform the following operation on a queue using array. printf("\n2.h> #include<conio.&c).rear. scanf("%d".c. void main() { int n.&n). INSERT"). switch(c) { case 1: printf("\nEnter the no u want to insert: "). break. printf("\n4. scanf("%d". front=0. case 0: exit(0). int front. printf("\n3. rear=-1. char ch. DELETE"). break. case 2: del().h> #include<stdlib. void del().

getch().i++) printf("%d ". scanf("%c". } else item=queue[front++]. for(i=front. } void del() { int item. } . } void display() { int i. } while(ch=='Y'||ch=='y'). if(front>rear) { printf("\nQueue is EMPTY"). } printf("\nDo you want to continue?(y/n)"). ch=getche().queue[i]). } else queue[++rear]=item. printf("\nThe elements of the Queue are: ").38 default: printf("\nWrong Choice").&ch).i<=rear. //fflush(stdin). } void insert(int item) { if(rear==MAXSIZE-1) { printf("\nQueue is FULL"). return. return.

39 Output:- Remarks:- A queue is a data structure in which operations are done on both of the ends of thiis data structure. . In a queue generally push operation is done on the rear edge And the pop operation is done on the front edge as it is behavioural in real world.

printf("\nEnter your choice: "). a) Insert ( ) b) Delete ( ) c) Display ( ) Program:#include<stdio. break.h> #include<stdlib. insert(n). break. void display(). case 3: display(). }node. void del(). void insert(int). void main() { int n. Insert").40 12. case 0: exit(0). node *rear=NULL. break. printf("\n3. scanf("%d". scanf("%d". printf("\n4. printf("\n1. char ch. Write a program to perform the following operation on a queue using linked list. switch(c) { case 1: printf("\nEnter the element: "). Exit"). do { printf("\n*********MENU*************"). case 2: del(). queue *next. Display"). Delete"). .h> typedef struct queue { int data.&n).&c).c. printf("\n2.

return. } } void del() { node *t. temp->next=NULL. } while(ch=='Y'||ch=='y').*t. } void display() { node *t. } else { for(t=rear. if(temp==NULL) { printf("Overflow"). free(t). fflush(stdin). temp=(node *)malloc(sizeof(node)).&ch). t->next=temp. rear=rear->next.t->data).t->next!=NULL.41 default: printf("Wrong Choice"). int x.t=t->next) { printf("\t%d". return. for(t=rear. } printf("\nDo u want to continue?(y/n)"). scanf("%c". return. x=rear->data. return. .t!=NULL. if(rear==NULL) { rear=temp.t=t->next). } temp->data=x. t=rear. } void insert(int x) { node *temp.

In using a link list in any data structure unwanted memory space is utilized fully. Here the structure is implemented using the limked list . .42 } } Output:- Remarks:- In this program the previous one data structure is operated but in another way.

Sign up to vote on this title
UsefulNot useful