[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Linked List

Home > Programs > Linked List

3 / 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: