3.e) Evaluate the following postfix notation of
expression : 10 20 + 25 15 - * 30 /
Ans) Children, Try this answer as an assignment.
OUTSIDE DELHI : 2005
3.c) Write a function in C++ to perform a
DELETE operation in a dynamically allocated queue considering the following
description :
struct Node
{ float U, V ;
Node *Link ;
} ;
class QUEUE
{
Node *Rear, *Front ;
public :
QUEUE( ) {Rear = NULL ;
Front = NULL ;}
void INSERT( ) ;
void DELETE( ) ;
~ QUEUE( ) ;
} ;
Solution: void Queue::DELETE( )
{
NODE *temp;
if(front= = NULL)
cout<<”\nQueue Underflow”;
else
{
cout<<”\nThe value of U of the element to delete: ““<<Front → U;
cout<<”\nThe value of V of the element to delete:“<<Front → V;
temp=Front;
Front=Front → Link;
delete temp;
}
}
3.e) Evaluate the following postfix notation of
expression : 20 10 + 5 2 * - 10 /.
Ans) Children, Try this answer as an
assignment.
2004:
3.d) Obtain the postfix notation for the following infix notation of expression showing the contents of the stack and postfix expression formed after each step of
conversion : (P—Q)/(R*(S—T)+U).
(Ans). ((P-Q)/((R*(S-T))+U))
S.N o |
Symbol Scanned |
Stack | Expression Y |
---|---|---|---|
1 | ( | ( | |
2 | ( | (( | |
3 | P | (( | P |
4 | - | ((- | P |
5 | Q | ((- | P Q |
6 | ) | ( | P Q - |
7 | / | (/ | P Q - |
8 | ( | (/( | P Q - |
9 | ( | (/(( | P Q - |
10 | R | (/(( | P Q - |
11 | * | (/((* | P Q - R |
12 | ( | (/((*( | P Q - R |
13 | S | (/((*( | P Q - R |
14 | - | (/((*(- | P Q - R S |
15 | T | (/((*(- | P Q - R S |
16 | ) | (/((* | P Q - R S T |
17 | ) | (/( | P Q - R S T - |
18 | + | (/(+ | P Q - R S T - * |
19 | U | (/(+ | P Q - R S T - * U + |
20 | ) | (/ | P Q - R S T - * U+ |
21 | ) | P Q - R S T - * U+ / |
Postfix Form: PQ-RST-*U+/
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )