Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Linked List

Home > Programs > Linked List

4 / 16

Write a program to implement the stack and queue using list

Answer:

#include       
#include 
#include  
#include   
/*Creating a NODE Structure*/
struct node
{
   int data;
   struct node *next;
};
 
/*Creating a class QUEUE*/
class queue
{
   struct node *frnt,*rear;
   public:
      queue() // constructure
      {
     frnt=rear=NULL;
      }
      void insert(); /*to insert an element*/
      void del();  /* to delete an element*/
      void show(); /* to show the stack*/
};
/* Insertion */
void queue::insert()
{
   int value;
   struct node *ptr;
   coutnext=NULL;
   if(frnt==NULL)
      frnt=ptr;
   else
      rear->next=ptr;
   rear=ptr;
   cout

Asked In :: Virtusa

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: