physics chemistry maths science forums
become expert I help I sign up I login
refer a friend - earn nickels!!   
 advanced
 
Home
Ask & Discuss Questions
Study Material
Experts Zone
Hang Out!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: stacks and queue
Forum Index -> Computer Science like the article? email it to a friend.  
Author Message
paddy.dude (1023)

Blazing goIITian

Olaaa!! Perrrfect answer. 155  [279 rates]

paddy.dude's Avatar

total posts: 1303    
offline Offline
what r the important thngs in this chapter to study for the board exams...........i find it very boring
    
K4FECN6 (102)

Hot goIITian

Olaaa!! Perrrfect answer. 16  [27 rates]

K4FECN6's Avatar

total posts: 104    
offline Offline
Conversion of Infix to Postfix/Prefix (or) Evaluation of Postfix expression are some sure questions from this chapter.Plus you need to go through all the algorithms(Stack implentation,Queue Implementation,Circular queue....).

ANAND KRISHNAN
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
srini (305)

Blazing goIITian

Olaaa!! Perrrfect answer. 49  [79 rates]

srini's Avatar

total posts: 536    
offline Offline
HEY,
AGREED IT IS DAMN BORING

GIVE LIFE THE BEST....srini...
DO OR DIE, OR BETTER NEVER TRY!!
I dont want to be the most intelligent among the ten.i pray the other nine RE fools!???!!!!!!
it doesn't matter if you win... whats important to me is i win!!!!!!!!
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
sid.shah.90 (601)

Blazing goIITian

Olaaa!! Perrrfect answer. 103  [146 rates]

sid.shah.90's Avatar

total posts: 358    
online Online
Push and pop in linked list implemented stacks and in queues, evaluation of postfix using stacks, circular queues

______________________________________________
Siddhant Shah


The trouble with doing something right the first time is that nobody appreciates how difficult it is.
You can't control the wind, but you can adjust your sails.
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
rshm15varma (162)

Hot goIITian

Olaaa!! Perrrfect answer. 28  [39 rates]

rshm15varma's Avatar

total posts: 183    
offline Offline
bacha kya????
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
nadeemoidu (1184)

Blazing goIITian

Olaaa!! Perrrfect answer. 200  [292 rates]

nadeemoidu's Avatar

total posts: 487    
offline Offline
if u r ready to loose 3-5 marks out of 70 , then u can leave it.


but if u think that this part is boring , then don't even think about taking computer science engineering bcos a major part of the course is algorithms and it will much more difficult than stack and queues.
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
paddy.dude (1023)

Blazing goIITian

Olaaa!! Perrrfect answer. 155  [279 rates]

paddy.dude's Avatar

total posts: 1303    
offline Offline
thnks guys........
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
varshavallig (798)

Blazing goIITian

Olaaa!! Perrrfect answer. 136  [195 rates]

varshavallig's Avatar

total posts: 509    
offline Offline
if u see it ,u will find that some of them have the basic process common.so just study one of them and the others will fall in.mainly they will ask only the user defined function and not the entire prog.

!!!!!!!!!!!!!!!!!!

Varsha
be cool,
tomorrow is what we make it today,
so if u can dream it , u can make it .
life is an ice cream ,eat it before it melts away!!!!!!!!!
varsha

SmileyCentral.com




 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
sugargal_anu (169)

Hot goIITian

Olaaa!! Perrrfect answer. 31  [38 rates]

sugargal_anu's Avatar

total posts: 135    
offline Offline
I thought the programs given in the textbook by Sumitha Arora were quite confusing. So here's a sample program I got from my school.

//Stack as an array
#include<iostream.h>
#include<iomanip.h>
#include<process.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
struct stack
{
    int no;
    char name[20];
    float sal;
    void accept()
    {
        cout<<"\nEmployee Number: ";
        cin>>no;
        cout<<"Name           : ";
        gets(name);
        cout<<"Salary         : ";
        cin>>sal;
    }
    void output()
    {
        cout<<"\nEmployee Number: "<<no;
        cout<<"\nName           : "<<name;
        cout<<"\nSalary         : "<<sal;
    }
};
void push(stack a[], int &top)
{
    if(top==4)
        cout<<"\nOverflow\n";
    else
    {
        top++;
        a[top].accept();
    }
}
void pop(stack a[], int &top)
{
    if(top==-1)
        cout<<"\nUnderflow\n";
    else
    {
        cout<<"\nDeleting\n";
        a[top].output();
        top--;
    }
}
void display(stack a[], int top)
{
    if(top==-1)
        cout<<"\nUnderflow\n";
    else
    {
        int i,l;
        cout<<endl<<setw(60)<<setfill('-')<<" "<<endl;
        cout<<setw(4)<<"Employee no"<<"\t\t"<<"Employee name "<<"\t\t"<<" Salary"<<endl;
        cout<<setw(60)<<setfill('-')<<" "<<endl;
        cout<<setw(60)<<setfill(' ')<<" "<<endl;
        for(i=0;i<=top;i++)
        {
            l=strlen(a[i].name);
            cout<<setw(8)<<a[i].no<<"\t\t"<<a[i].name;
            cout<<setw(28-l)<<a[i].sal<<endl;
        }
        cout<<setw(60)<<setfill('-')<<" "<<endl;
        cout<<setw(60)<<setfill(' ')<<" "<<endl;
    }
}
void main()
{
    clrscr();
    stack emp[5];
    int top=-1,op;
    char ch;
    do
    {
        cout<<"\nThe menu is:-";
        cout<<"\n1.Push\n2.Pop\n3.Display\n4.Exit\n";
        cout<<"Enter your choice: ";
        cin>>op;
        if(op==1)
            push(emp,top);
        if(op==2)
            pop(emp,top);
        if(op==3)
            display(emp,top);
        if(op==4)
            exit(0);
        cout<<"\nDo you want to continue? ";
        cin>>ch;
    }while(ch=='y'||ch=='Y');
}

Orkut Graphics - Angels
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
sugargal_anu (169)

Hot goIITian

Olaaa!! Perrrfect answer. 31  [38 rates]

sugargal_anu's Avatar

total posts: 135    
offline Offline
//Stack as linked list
#include<iostream.h>
#include<process.h>
#include<conio.h>
struct stack
{
    int no;
    char name[20];
    stack *link;
    void accept()
    {
        cout<<"Enter no. & name: ";
        cin>>no>>name;
    }
    void output()
    {
        cout<<no<<" "<<name;
    }
};
void push(stack *&top)
{
    stack *temp;
    temp=new stack;
    temp->accept();
    temp->link=NULL;
    if(top==NULL)
        top=temp;
    else
    {
        temp->link=top;
        top=temp;
    }
}
void pop(stack *&top)
{
    if(top==NULL)
        cout<<"Underflow";
    else
    {
        stack *temp;
        temp=new stack;
        temp=top;
        cout<<"Deleting ";
        temp->output();
        top=top->link;
        delete temp;
    }
}
void display(stack *top)
{
    if(top==NULL)
        cout<<"Underflow";
    else
    {
        while(top)
        {
            top->output();
            top=top->link;
        }
    }
}
void main()
{
    stack *top;
    top=new stack;
    top=NULL;
    char ch;
    int op;
    do
    {
        cout<<"\n1.Push\n2.Pop\n3.Display\n4.Exit\n";
        cout<<"Enter your choice ";
        cin>>op;
        if(op==1)
            push(top);
        if(op==2)
            pop(top);
        if(op==3)
            display(top);
        if(op==4)
            exit(0);
        cout<<"\nWant to continue? ";
        cin>>ch;
    }while(ch=='y'||ch=='Y');
}

Orkut Graphics - Angels
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
sugargal_anu (169)

Hot goIITian

Olaaa!! Perrrfect answer. 31  [38 rates]

sugargal_anu's Avatar

total posts: 135    
offline Offline
//queue as an array
#include<iostream.h>
#include<process.h>
#include<conio.h>
struct queue
{
    int no;
    char name[20];
    void accept()
    {
        cout<<"Enter no. & name ";
        cin>>no>>name;
    }
    void output()
    {
        cout<<no<<" "<<name;
    }
};
void qinsert(queue q[],int &front,int &rear,int n)
{
    if(rear==n-1)
        cout<<"\nQueue is full\n";
    else
    {
        if(rear==-1)
            front=rear=0;
        else
            rear++;
        q[rear].accept();
    }
}
void qdelete(queue q[],int &front,int rear)
{
    if(rear==-1||front==rear+1)
        cout<<"\nQueue is empty\n";
    else
    {
        q[front].output();
        front++;
    }
}
void qdisplay(queue q[],int front,int rear)
{
    int i;
    for(i=front;i<=rear;i++)
        q[i].output();
}
void main()
{
    clrscr();
    queue q[10];
    int front,rear=-1,op,n;
    char ch;
    cout<<"Enter size of elements: ";
    cin>>n;
    do
    {
        cout<<"\n1.Insert\n2.Delete\n3.Display\n4.Exit\n";
        cout<<"Enter your choice ";
        cin>>op;
        switch(op)
        {
            case 1: qinsert(q,front,rear,n); break;
            case 2: qdelete(q,front,rear); break;
            case 3: qdisplay(q,front,rear); break;
            case 4: exit(0);
        }
        cout<<"\nDo you want to continue? ";
        cin>>ch;
    }while(ch=='y'||ch=='Y');
}

Orkut Graphics - Angels
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
sugargal_anu (169)

Hot goIITian

Olaaa!! Perrrfect answer. 31  [38 rates]

sugargal_anu's Avatar

total posts: 135    
offline Offline
//queue as linked list
#include<iostream.h>
#include<process.h>
#include<conio.h>
struct queue
{
    int no;
    char name[20];
    queue *link;
    void accept()
    {
        cout<<"Enter no. & name ";
        cin>>no>>name;
    }
    void output()
    {
        cout<<no<<" "<<name<<endl;
    }
};
void qinsert(queue *&front,queue *&rear)
{
    queue *temp;
    temp=new queue;
    temp->accept();
    temp->link=NULL;
    if(rear==NULL)
        front=rear=temp;
    else
    {
        rear->link=temp;
        rear=temp;
    }
}
void qdelete(queue *&front)
{
    if(front==NULL)
        cout<<"\nUnderflow\n";
    else
    {
        queue *temp;
        temp=new queue;
        temp=front;
        temp->output();
        front=front->link;
        delete temp;
    }
}
void qdisplay(queue *front,queue *rear)
{
    if(front==rear)
        cout<<"\nQueue is empty\n";
    else
        while(front)
        {
            front->output();
            front=front->link;
        }
}
void main()
{
    clrscr();
    queue *front, *rear;
    front=new queue;
    front=NULL;
    rear=new queue;
    rear=NULL;
    int op;
    char ch;
    do
    {
        cout<<"\n1.Insert\n2.Delete\n3.Display\n4.Exit\n";
        cout<<"Enter your choice ";
        cin>>op;
        if(op==1)
            qinsert(front,rear);
        if(op==2)
            qdelete(front);
        if(op==3)
            qdisplay(front,rear);
        if(op==4)
            exit(0);
        cout<<"\nWant to continue? ";
        cin>>ch;
    }while(ch=='y'||ch=='Y');
}

Orkut Graphics - Angels
 this reply: 2 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
LAMPARD (1142)

Blazing goIITian

Olaaa!! Perrrfect answer. 190  [286 rates]