Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

Ans:

((P-Q)/((R*(S-T))+U)) S.No 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 - R
11 * ( / ( ( * P Q - R
12 ( ( / ( ( * ( P Q - R
13 S ( / ( ( * ( P Q - R S
14 - ( / ( ( * ( - P Q - R S
15 T ( / ( ( * ( - P Q - R S T
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+/

Q.2. Define member functions queins( ) to insert nodes and quedel ( ) to delete nodes of the linked list implemented class queue, where each node has the following structure.
struct node
{ char name[20] ;
int age ;
node *Link ;
} ;
class queue
{ node *rear, *front ;
public :
queue( ) { rear = NULL; front = NULL} ;
void queins( ) ;
void quedel( ) ;
} ;
Solution:
void queue::queins( )
{ node *ptr;
ptr=new node;
if(ptr= = NULL)
{
cout<<”\nNo memory to create a new node….”;
exit(1);
} cout<<”\nEnter the name….”;
gets(ptrname);
cout<<”\nEnter the age…”;
cin>>ptrage;
ptrLink=NULL;
if(rear= = NULL)
front=rear=ptr;
else
{
rearLink=ptr;
rear=ptr;
}
}
void queue::quedel( )
{ node *temp;
if(front= = NULL)
cout<<”Queue Underflow”;
else
{ cout<<”\nThe name of the element to delete: “<<frontname;
cout<<”\nThe age of the element to delete: “<<frontage;
temp=front;
front=frontLink;
delete temp;
}
}

Paper By Mr. Ravi Kiran
Email Id : [email protected]