COMPUTER SCIENCE LINKED LISTS , STACKS AND QUEUES

DELHI : 2000

3.d) Evaluate the following postfix expression using a stack. Show the contents of stack after execution of each operation: 20, 8, 4, /, 2, 3, +, *, -

Ans) Children, Try this answer as an assignment.

3.e) Give necessary declarations for a queue containing float type numbers; also write a user defined function in C++ to insert a float type number in the queue. You should use linked representation of queue.

Solution:

struct NODE
{ float Number;
NODE *Link;
};
class Queue
{ NODE *front,*rear;
public:
Queue( )
{ front = rear = NULL; }
void Insert( );
void Delete( );
void Display( );
};
void Queue::Insert( ){
NODE *ptr;
ptr=new NODE;
if(ptr= = NULL)
{
cout<<”\nNo memory to create a new node….”;
exit(1);
}
cout<<”\nEnter the Number….”;
cin>>ptr → Number;
ptr → Link=NULL;
if(rear= = NULL)
front=rear=ptr;
else
{
rear → Link=ptr;
rear=ptr;
}
}

1999:

3 (d) Evaluate the following postfix expression using a stack and show the contents of the stack after execution of each operation 5,11,-,6,8,+,12,*,/

Ans) Children, Try this answer as an assignment.

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack11.php on line 122

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack11.php on line 122

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack11.php on line 124

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack11.php on line 124