Page 546 - Computer science 868 Class 12
P. 546

2.  Convert the following infix notation into postfix form:
                     a.   X + (Y - Z) + ((W + E)*F)/J                                                          [ISC 2015]
                     b.  A + B / C * ( D ^ E)  % F
                     c.  (A *  B * C / E) ^F + G
                     d.  ((P + Q * R - S) * T ) / (U + V)/ H
                     e.  X + (Y * Z) %  ((W + E) * F) - J)
                     f.  (A + B) / (C * (D - E)) + F * G
                     g.  (A + B) ^ (C * (D + E)) - F - G
                     h.  ((P + Q - R + S) * T ) / (U + V) * H
                     i.  ((P + Q ^ R - S) % T ) / (U - V) + H
                     j.  X / (Y * Z) - ( W+ E * F) + J
                  3.  Convert the following infix notations into prefix forms:
                     a.  X + Y * Z  + ((W + E) ^ F)/J
                     b.  A + B / C * ( D ^ E) % F
                     c.  (A * B * C / E) ^ F - G + H - I
                     d.  ((P + Q * R - S) * T ) / (U + V)/ H
                     e.  X + (Y * Z) % (W + E )* (F - J
                     f.  (A + B) / (C * (D - E)) + F * G
                     g.  (A + B) ^ (C * (D + E)) - F - G
                     h.  ((P + Q * R + S) +  T ) / (U + V) * H
                     i.  ((P + Q ^ R - S) % T ) / (U - V) + H
                     j.  X / (Y * Z) - ( W + E * F) + J
                  4.  Email is an entity which can store message with the restriction that an element can be added or removed from the top only. The
                    details of class Stack are given below.
                    Class name                           :  Email
                     Data Members
                     msg[]                               :  an array to hold maximum of 50 messages
                     size                                :  the maximum capacity of the string array
                     top                                 :  the index of the topmost element of the stack
                     Member Functions
                     Email (int x)                       :  constructor to initialise size = x and top = -1
                     void pushMail(String m)             :   to push message into the stack. If the stack is full, display the message “Mail
                                                           cannot be stored…overflow”
                     void popMail()                      :   to remove message from the top of the stack and display it. If the stack is
                                                           empty, display the message “Empty…underflow”
                     void display()                      :  to display the elements of the stack
                     Specify class Email giving details of the constructor(), void pushMail(String), void popMail() and void display().
                  5.  A CharStk is an entity which can hold a maximum of 100 characters. It enables the user to add and remove names from the
                    topmost end only. Define a class CharStk with the following details.
                     Class name                          :  CharStk
                     Data Members
                     ch[]                                :  an array to store character
                     cap                                 :  the maximum capacity of the string array
                     top                                 :  the index of the topmost element of the stack
                     Member Functions
                     CharStk (int max)                   :  constructor to initialise cap = max and top = -1 and define the string array
                     void pushChar(char c)               :  to push character c into the stack. If the stack is full, display the message
                                                           “overflow”
                     char popChar()                      :   to remove and return the character from the topmost location CharStk if any,
                                                           else return ‘\0’



                544544  Touchpad Computer Science-XII
   541   542   543   544   545   546   547   548   549   550   551