πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

Multiplication of two polynomials using Linked list

Given two polynomials in the form of linked list. The task is to find the multiplication of both polynomials.

Examples: 

Input: Poly1: 3x^2 + 5x^1 + 6, Poly2: 6x^1 + 8
Output: 18x^3 + 54x^2 + 76x^1 + 48
On multiplying each element of 1st polynomial with 
elements of 2nd polynomial, we get
18x^3 + 24x^2 + 30x^2 + 40x^1 + 36x^1 + 48
On adding values with same power of x,
18x^3 + 54x^2 + 76x^1 + 48

Input: Poly1: 3x^3 + 6x^1 - 9, Poly2: 9x^3 - 8x^2 + 7x^1 + 2
Output: 27x^6 - 24x^5 + 75x^4 - 123x^3 + 114x^2 - 51x^1 - 18

Approach: 

  1. In this approach we will multiply the 2nd polynomial with each term of 1st polynomial.
  2. Store the multiplied value in a new linked list.
  3. Then we will add the coefficients of elements having the same power in resultant polynomial.

Below is the implementation of the above approach: 

#include <stdio.h>
#include <conio.h>
#include <alloc.h>

/* structure representing a node of a linked list. The node can store a term of a polynomial */
struct polynode
{
    float coeff ;
    int exp ;
    struct polynode *link ;
} ;

void poly_append ( struct polynode **, float, int ) ;
void display_poly ( struct polynode * ) ;
void poly_multiply ( struct polynode *, struct polynode *, struct polynode ** ) ;
void padd ( float, int, struct polynode ** ) ;

void main( )
{
    struct polynode *first, *second, *mult ;
    int i = 1 ;

    first = second = mult = NULL ;  /* empty linked lists */

    poly_append ( &first, 3, 5 ) ;
    poly_append ( &first, 2, 4 ) ;
    poly_append ( &first, 1, 2 ) ;

    clrscr( ) ;
    display_poly ( first ) ;

    poly_append ( &second, 1, 6 ) ;
    poly_append ( &second, 2, 5 ) ;
    poly_append ( &second, 3, 4 ) ;

    printf ( \"\\n\\n\" ) ;
    display_poly ( second ) ;

    printf ( \"\\n\" );
    while ( i++ < 79 )
        printf ( \"-\" ) ;

    poly_multiply ( first, second, &mult ) ;

    printf ( \"\\n\\n\" ) ;
    display_poly ( mult ) ;
}

/* adds a term to a polynomial */
void poly_append ( struct polynode **q, float x, int y )
{
    struct polynode *temp ;
    temp = *q ;

    /* create a new node if the list is empty */
    if ( *q == NULL )
    {
        *q = malloc ( sizeof ( struct polynode ) ) ;
        temp = *q ;
    }
    else
    {
        /* traverse the entire linked list */
        while ( temp -> link != NULL )
            temp = temp -> link ;

        /* create new nodes at intermediate stages */
        temp -> link = malloc ( sizeof ( struct polynode ) ) ;
        temp = temp -> link ;
    }

    /* assign coefficient and exponent */
    temp -> coeff = x ;
    temp -> exp = y ;
    temp -> link = NULL ;
}

/* displays the contents of linked list representing a polynomial */
void display_poly ( struct polynode *q )
{
    /* traverse till the end of the linked list */
    while ( q != NULL )
    {
        printf ( \"%.1f x^%d  :  \", q -> coeff, q -> exp ) ;
        q = q -> link ;
    }

    printf ( \"\\b\\b\\b \" ) ;  /* erases the last colon(:) */
}

/* multiplies the two polynomials */
void poly_multiply ( struct polynode *x, struct polynode *y,
                   struct polynode **m )
{
    struct polynode *y1 ;
    float coeff1, exp1 ;

    y1 = y ;  /* point to the starting of the second linked list */

    if ( x == NULL && y == NULL )
        return ;

    /* if one of the list is empty */
    if ( x == NULL )
        *m = y ;
    else
    {
        if ( y == NULL )
            *m = x ;
        else  /* if both linked lists exist */
        {
            /* for each term of the first list */
            while ( x != NULL )
            {
                /* multiply each term of the second linked list with a 
                    term of the first linked list */
                while ( y != NULL )
                {
                    coeff1 = x -> coeff * y -> coeff ;
                    exp1 = x -> exp + y -> exp ;
                    y = y -> link ;

                    /* add the new term to the resultant polynomial */
                    padd ( coeff1, exp1, m ) ;
                }

                y = y1 ;  /* reposition the pointer to the starting of
                         the second linked list */

                x = x -> link ;  /* go to the next node */
            }
        }
    }
}

/* adds a term to the polynomial in the descending order of the exponent */
void padd ( float c, int e, struct polynode **s )
{
    struct polynode *r, *temp = *s ;

    /* if list is empty or if the node is to be inserted before the first node */
    if ( *s == NULL || e > ( *s ) -> exp )
    {
        *s = r = malloc ( sizeof ( struct polynode ) ) ;
        ( *s ) -> coeff = c ;
        ( *s ) -> exp = e ;
        ( *s ) -> link = temp ;
    }
    else
    {
        /* traverse the entire linked list to search the position to insert a new node */
        while ( temp != NULL )
        {
            if ( temp -> exp == e )
            {
                temp -> coeff += c ;
                return ;
            }

            if ( temp -> exp > e && ( temp -> link -> exp < e ||    temp -> link == NULL ) )
            {
                r = malloc ( sizeof ( struct polynode ) ) ;
                r -> coeff = c;
                r -> exp = e ;
                r -> link = temp -> link ;
                temp -> link = r ;
                return ;
            }

            temp = temp -> link ;  /* go to next node */
        }

        r -> link = NULL ;
        temp -> link = r ;
    }
}

Labels: ,

Adding two polynomials using Linked List

Given two polynomial numbers represented by a linked list. Write a function that add these lists means add the coefficients who have same variable powers.

Example:  

Input:
     1st number = 5x2 + 4x1 + 2x0
     2nd number = -5x1 - 5x0
Output:
        5x2-1x1-3x0
Input:
     1st number = 5x3 + 4x2 + 2x0
     2nd number = 5x^1 - 5x^0
Output:
        5x3 + 4x2 + 5x1 - 3x0

Addition-of-two-polynomial


Five functions are designed in the program:

  1. Init() is used to initialize the linked list;
  2. CreatFromTail() creates a linked list by tail interpolation;
  3. Polyadd() is used to realize the addition algorithm of two polynomials;
  4. Polysub() is used to realize the subtraction of two polynomials;
  5. Print() is used to output polynomials.
    #include<stdio.h>
    #include<stdlib.h>
    #include<malloc.h>
    typedef struct poly
    {
    	int exp; 	//index 
    	int coef;	//coefficient 
    	struct poly *next;
    	
    }PNode,*PLinklist;
    /*Linked list initialization*/
    int Init(PLinklist *head)
    {
    	*head=(PLinklist)malloc(sizeof(PNode));
    	if(*head)
    	{
    		(*head)->next=NULL;
    		return 1;
    	}
    	else
    		return 0;		
    }
    /*Creating linked list by tail interpolation*/ 
    int CreateFromTail(PLinklist*head)
    {
    	PNode *pTemp,*pHead;
    	int c;		//Storage factor 
    	int exp;	//Storage index 
    	int i=1	;	//Counter 
    	pHead=*head;
    	scanf("%d,%d",&c,&exp);
    	while(c!=0)//When the coefficient is zero, end the input
    	{
    		pTemp=(PLinklist)malloc(sizeof(PNode));
    		if(pTemp)
    		{
    			pTemp->exp=exp;		//Acceptance index 
    			pTemp->coef=c;		//Acceptance coefficient 
    			pTemp->next=NULL;
    			pHead->next=pTemp;
    			pHead=pTemp;
    			scanf("%d,%d",&c,&exp);
    		 } 
    		 else
    		 return 0;
    	 } 
    	 return 1;
    }
    /*Add two polynomials*/ 
    void Polyadd(PLinklist LA,PLinklist LB)
    {
    	PNode*LAI=LA->next;		//Pointer LAI moves in polynomial A 
    	PNode*LBI=LB->next;		 
    	PNode*temp;				//Pointer temp saves the node to be deleted 
    	int sum=0;				//Sum of preservation factors 
    	/*Compare the exponential terms of the nodes referred to by LAI and LBI*/ 
    	while(LAI&&LBI)
    	{
    		if(LAI->exp<LBI->exp){		  
    			LA->next=LAI;
    			LA=LA->next;
    			LAI=LAI->next;
    		}
    		else if(LAI->exp==LBI->exp)
    		{
    			sum=LAI->coef+LBI->coef;
    			if(sum)
    			{
    				LAI->coef=sum;
    				LA->next=LAI;
    				LA=LA->next;
    				LAI=LAI->next;
    				temp=LBI;
    				LBI=LBI->next;
    				free(temp);
    				
    			}
    			else
    			{
    				temp=LAI;
    				LAI=LAI->next;
    				free(temp);
    				temp=LBI;
    				LBI=LBI->next;
    				free(temp);
    				
    			}
    		}
    		else
    		{
    			LA->next=LBI;
    			LA=LA->next;
    			LBI=LBI->next;
    		}
    		
    	}
    	if(LAI)
    		LA->next=LAI;
    	else
    		LA->next=LBI; 
    }
    /*Subtraction of two polynomials*/ 
    void Polysub(PLinklist LA,PLinklist LB)
    {
    	PNode*LAI=LA->next;		//Pointer LAI moves in polynomial A 
    	PNode*LBI=LB->next;		 
    	PNode*temp;				//Pointer temp saves the node to be deleted 
    	int difference=0;				//Preservation factor
    	/*Compare the exponential terms of the nodes referred to by LAI and LBI*/ 
    	while(LAI&&LBI)
    	{
    		if(LAI->exp<LBI->exp){		  
    			LA->next=LAI;
    			LA=LA->next;
    			LAI=LAI->next;
    		}
    		else if(LAI->exp==LBI->exp)
    		{
    			difference=LAI->coef-LBI->coef;
    			if(difference)
    			{
    				LAI->coef=difference;
    				LA->next=LAI;
    				LA=LA->next;
    				LAI=LAI->next;
    				temp=LBI;
    				LBI=LBI->next;
    				free(temp);
    				
    			}
    			else
    			{
    				temp=LAI;
    				LAI=LAI->next;
    				free(temp);
    				temp=LBI;
    				LBI=LBI->next;
    				free(temp);
    				
    			}
    		}
    		else
    		{
    			LA->next=LBI;
    			LA=LA->next;
    			LBI=LBI->next;
    		}
    		
    	}
    	if(LAI)
    		LA->next=LAI;
    	else
    		LA->next=LBI; 
    }
    void Print(PLinklist head)
    {
    	head=head->next;
    	while(head)
    	{
    		if(head->exp)
    			printf("(%dx^%d)",head->coef,head->exp);
    		else
    			printf("%d",head->coef);
    		if(head->next)
    			printf("+");
    		else
    			break;
    		head=head->next;
    	}
    }
    
    int main(void)
    {
    	PLinklist LA;
    	PLinklist LB;
    	Init(&LA);
    	Init(&LB);
    	printf("Please enter the coefficient of the first polynomial,index,Enter 0,0 End input\n");
    	CreateFromTail(&LA);
    	printf("Please enter the coefficient of the second polynomial,index,Enter 0,0 End input\n");
    	CreateFromTail(&LB);
    	Print(LA);
    	printf("\n");
    	Print(LB);
    	printf("\n");
    	
    	int i; 
    	
    	printf("(Please enter 1 for addition polynomial and 0 for subtraction polynomial)\n"); 
    	scanf("%d",&i);
    	
    	if(1==i){
    		Polyadd(LA,LB);
    		printf("The result of adding two polynomials:\n");
    		Print(LA);
    		printf("\n");
    	}
    	else if(0==i){
    		Polysub(LA,LB);
    		printf("The result of subtracting two polynomials:\n");
    		Print(LA);
    		printf("\n");
    	}
    	else 
    		printf("Please enter the correct characters");
    	return 0;
    	
    }




Labels: ,

Polynomial representation using Linked List

The linked list can be used to represent a polynomial of any degree. Simply the information field is changed according to the number of variables used in the polynomial. If a single variable is used in the polynomial the information field of the node contains two parts: one for coefficient of variable and the other for degree of variable. Let us consider an example to represent a polynomial using linked list as follows:

Polynomial:      3x3-4x2+2x-9
Linked List:

In the above linked list, the external pointer β€˜ROOT’ point to the first node of the linked list. The first node of the linked list contains the information about the variable with the highest degree. The first node points to the next node with next lowest degree of the variable.
Representation of a polynomial using the linked list is beneficial when the operations on the polynomial like addition and subtractions are performed. The resulting polynomial can also be traversed very easily to display the polynomial.



The above two linked lists represent the polynomials,3x3-4x2+2x-9 and 5x3-2x2+6x+3 respectively. If both the polynomials are added then the resulting linked will be:



The linked list pointer ROOT gives the representation for polynomial, 8x3-6x2+8x-6.

C program to read and display a polynomial using Linked List:

#inculde<stdio.h>
#inculde<stdlib.h>
#inculde<conio.h>
struct node
{
int coeft;
int degree;
struct node *link;
};
typedef struct node poly;
main()
{
poly *root,*temp,*new;
int hdegree, coeft;
root=NULL;
clrscr();
printf(β€œEnter the highest degree of polynomial:”)
scanf(β€œ%d”,&hdegree);
while(hdegree>=0)
{
printf(β€œEnter coefficient of variable with degree %d”,hdegree);
scanf(β€œ%d”,&coeft);
if(coeft!=0)
{
new=(poly*)malloc(sizeof(poly));
if(new= =NULL)
{
printf(β€œMemory allocation error…”); exit(0);
}
new->coeft=coeft;
new->degree=hdegree;
new->link=NULL;
if(root= =NULL)
{
root=new;
temp=root;
}
else
{
temp->link=new;
temp=new;
}
}
hdegree--;
}
clrscr();
printf(β€œ\n The Polynomial is:\n\n”);
temp=root;
while(temp!=NULL)
{
if(temp->coeft>0)
 printf(β€œ+%dx%d”,temp->coeft,temp->degree);
else
  printf(β€œ%dx%d”,temp->coeft,temp->degree);
temp=temp->link;
}
 getch();
}

Labels: ,

Circular Doubly Linked List

Circular doubly linked list is a more complexed type of data structure in which a node contain pointers to its previous node as well as the next node. Circular doubly linked list doesn't contain NULL in any of the node. The last node of the list contains the address of the first node of the list. The first node of the list also contain address of the last node in its previous pointer.

A circular doubly linked list is shown in the following figure.


Circular Doubly Linked List

Due to the fact that a circular doubly linked list contains three parts in its structure therefore, it demands more space per node and more expensive basic operations. However, a circular doubly linked list provides easy manipulation of the pointers and the searching becomes twice as efficient.

Memory Management of Circular Doubly linked list

The following figure shows the way in which the memory is allocated for a circular doubly linked list. The variable head contains the address of the first element of the list i.e. 1 hence the starting node of the list contains data A is stored at address 1. Since, each node of the list is supposed to have three parts therefore, the starting node of the list contains address of the last node i.e. 8 and the next node i.e. 4. The last node of the list that is stored at address 8 and containing data as 6, contains address of the first node of the list as shown in the image i.e. 1. In circular doubly linked list, the last node is identified by the address of the first node which is stored in the next part of the last node therefore the node which contains the address of the first node, is actually the last node of the list.

Circular Doubly Linked List

Operations on circular doubly linked list :

There are various operations which can be performed on circular doubly linked list. The node structure of a circular doubly linked list is similar to doubly linked list. However, the operations on circular doubly linked list is described in the following table.

SNOperationDescription
1Insertion at beginning
Adding a node in circular doubly linked list at the beginning.
2Insertion at end
Adding a node in circular doubly linked list at the end.
3Deletion at beginning
Removing a node in circular doubly linked list from beginning.
4Deletion at end
Removing a node in circular doubly linked list at the end.

Traversing and searching in circular doubly linked list is similar to that in the circular singly linked list.

C program to implement all the operations on circular doubly linked list

  1. #include<stdio.h>  
  2. #include<stdlib.h>  
  3. struct node  
  4. {  
  5.     struct node *prev;  
  6.     struct node *next;  
  7.     int data;  
  8. };  
  9. struct node *head;  
  10. void insertion_beginning();  
  11. void insertion_last();  
  12. void deletion_beginning();  
  13. void deletion_last();  
  14. void display();  
  15. void search();  
  16. void main ()  
  17. {  
  18. int choice =0;  
  19.     while(choice != 9)  
  20.     {  
  21.         printf("\n*********Main Menu*********\n");  
  22.         printf("\nChoose one option from the following list ...\n");  
  23.         printf("\n===============================================\n");  
  24.         printf("\n1.Insert in Beginning\n2.Insert at last\n3.Delete from Beginning\n4.Delete from last\n5.Search\n6.Show\n7.Exit\n");  
  25.         printf("\nEnter your choice?\n");  
  26.         scanf("\n%d",&choice);  
  27.         switch(choice)  
  28.         {  
  29.             case 1:  
  30.             insertion_beginning();  
  31.             break;  
  32.             case 2:  
  33.                     insertion_last();  
  34.             break;  
  35.             case 3:  
  36.             deletion_beginning();  
  37.             break;  
  38.             case 4:  
  39.             deletion_last();  
  40.             break;  
  41.             case 5:  
  42.             search();  
  43.             break;  
  44.             case 6:  
  45.             display();  
  46.             break;  
  47.             case 7:  
  48.             exit(0);  
  49.             break;  
  50.             default:  
  51.             printf("Please enter valid choice..");  
  52.         }  
  53.     }  
  54. }  
  55. void insertion_beginning()  
  56. {  
  57.    struct node *ptr,*temp;   
  58.    int item;  
  59.    ptr = (struct node *)malloc(sizeof(struct node));  
  60.    if(ptr == NULL)  
  61.    {  
  62.        printf("\nOVERFLOW");  
  63.    }  
  64.    else  
  65.    {  
  66.     printf("\nEnter Item value");  
  67.     scanf("%d",&item);  
  68.     ptr->data=item;  
  69.    if(head==NULL)  
  70.    {  
  71.       head = ptr;  
  72.       ptr -> next = head;   
  73.       ptr -> prev = head;   
  74.    }  
  75.    else   
  76.    {  
  77.        temp = head;   
  78.     while(temp -> next != head)  
  79.     {  
  80.         temp = temp -> next;   
  81.     }  
  82.     temp -> next = ptr;  
  83.     ptr -> prev = temp;  
  84.     head -> prev = ptr;  
  85.     ptr -> next = head;  
  86.     head = ptr;  
  87.    }  
  88.    printf("\nNode inserted\n");  
  89. }  
  90.      
  91. }  
  92. void insertion_last()  
  93. {  
  94.    struct node *ptr,*temp;  
  95.    int item;  
  96.    ptr = (struct node *) malloc(sizeof(struct node));  
  97.    if(ptr == NULL)  
  98.    {  
  99.        printf("\nOVERFLOW");  
  100.    }  
  101.    else  
  102.    {  
  103.        printf("\nEnter value");  
  104.        scanf("%d",&item);  
  105.         ptr->data=item;  
  106.        if(head == NULL)  
  107.        {  
  108.            head = ptr;  
  109.            ptr -> next = head;   
  110.            ptr -> prev = head;   
  111.        }  
  112.        else  
  113.        {  
  114.           temp = head;  
  115.           while(temp->next !=head)  
  116.           {  
  117.               temp = temp->next;  
  118.           }  
  119.           temp->next = ptr;  
  120.           ptr ->prev=temp;  
  121.           head -> prev = ptr;  
  122.       ptr -> next = head;  
  123.         }  
  124.    }  
  125.      printf("\nnode inserted\n");  
  126. }  
  127.   
  128. void deletion_beginning()  
  129. {  
  130.     struct node *temp;  
  131.     if(head == NULL)  
  132.     {  
  133.         printf("\n UNDERFLOW");  
  134.     }  
  135.     else if(head->next == head)  
  136.     {  
  137.         head = NULL;   
  138.         free(head);  
  139.         printf("\nnode deleted\n");  
  140.     }  
  141.     else  
  142.     {  
  143.         temp = head;   
  144.         while(temp -> next != head)  
  145.         {  
  146.             temp = temp -> next;  
  147.         }  
  148.         temp -> next = head -> next;  
  149.         head -> next -> prev = temp;  
  150.         free(head);  
  151.         head = temp -> next;  
  152.     }  
  153.   
  154. }  
  155. void deletion_last()  
  156. {  
  157.     struct node *ptr;  
  158.     if(head == NULL)  
  159.     {  
  160.         printf("\n UNDERFLOW");  
  161.     }  
  162.     else if(head->next == head)  
  163.     {  
  164.         head = NULL;   
  165.         free(head);   
  166.         printf("\nnode deleted\n");  
  167.     }  
  168.     else   
  169.     {  
  170.         ptr = head;   
  171.         if(ptr->next != head)  
  172.         {  
  173.             ptr = ptr -> next;   
  174.         }  
  175.         ptr -> prev -> next = head;  
  176.         head -> prev = ptr -> prev;    
  177.         free(ptr);  
  178.         printf("\nnode deleted\n");  
  179.     }  
  180. }  
  181.   
  182. void display()  
  183. {  
  184.     struct node *ptr;  
  185.     ptr=head;  
  186.     if(head == NULL)  
  187.     {  
  188.         printf("\nnothing to print");  
  189.     }     
  190.     else  
  191.     {  
  192.         printf("\n printing values ... \n");  
  193.           
  194.         while(ptr -> next != head)  
  195.         {  
  196.           
  197.             printf("%d\n", ptr -> data);  
  198.             ptr = ptr -> next;  
  199.         }  
  200.         printf("%d\n", ptr -> data);  
  201.     }  
  202.               
  203. }  
  204.   
  205. void search()  
  206. {  
  207.     struct node *ptr;  
  208.     int item,i=0,flag=1;  
  209.     ptr = head;   
  210.     if(ptr == NULL)  
  211.     {  
  212.         printf("\nEmpty List\n");  
  213.     }  
  214.     else  
  215.     {   
  216.         printf("\nEnter item which you want to search?\n");   
  217.         scanf("%d",&item);  
  218.         if(head ->data == item)  
  219.         {  
  220.         printf("item found at location %d",i+1);  
  221.         flag=0;  
  222.         }  
  223.         else   
  224.         {  
  225.         while (ptr->next != head)  
  226.         {  
  227.             if(ptr->data == item)  
  228.             {  
  229.                 printf("item found at location %d ",i+1);  
  230.                 flag=0;  
  231.                 break;  
  232.             }   
  233.             else  
  234.             {  
  235.                 flag=1;  
  236.             }  
  237.             i++;  
  238.             ptr = ptr -> next;  
  239.         }  
  240.         }  
  241.         if(flag != 0)  
  242.         {  
  243.             printf("Item not found\n");  
  244.         }  
  245.     }     
  246.           
  247. }  

Output:

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
1

Enter Item value123

Node inserted

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
2

Enter value234

node inserted

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
1

Enter Item value90

Node inserted

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
2

Enter value80

node inserted

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
3

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
4

node deleted

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
6

 printing values ... 
123

*********Main Menu*********

Choose one option from the following list ...

===============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
5

Enter item which you want to search?
123
item found at location 1
*********Main Menu*********

Choose one option from the following list ...

============================================

1.Insert in Beginning
2.Insert at last
3.Delete from Beginning
4.Delete from last
5.Search
6.Show
7.Exit

Enter your choice?
7

Labels: ,