ADT of STACK

The best book for data structure is your class note book. follow concept of each topic and exercise each question as much you can. If you stuck anywhere  refer note book concept and try to understand flow of execution, trace the algorithm.

However if you have completed your class notes and want more exercise problem then  refer book  Cormen. But i shall personally suggest you whatever sir has discussed in class is more then enough.


Here are some problems i have discussed in TA class :

1) Infix to Postfix:
A/B^C+D*E-A*C      
 Answer : Postfix : ABC^/DE*+AC*-
                 Prefix  : -+/A^BC*DE*AC


2) B^2-4*A*C^1/2

Answer: Postfix:  B2^4A*C*-12/^
               Prefix :  ^-^B2**4AC/12

3)  a= -b+c*d/e - f ^g^h + i * j

Answer : Postfix :  ab-cd*e/+fgh^^ij*+-
                Prefix   :  a-+-b/*cde+^f^gh*ij

4)  log x

Answer:  Postfix: x log
                Prefix : log x

5) x !

Answer : Postfix : x !
                Prefix : ! x


Precedence (High to low)

   -   (unary operation)
   ^     (Exponential : Right to Left)
   * /   (multiplication and division : Left to Right)
  + -  (Left to right)
   =   (Right to Left)


Question based on expression evaluation :

1) 2,3,+,1,8,9,^,^,6,*,+,1,-

       Answer : 10

2)  -, +, -, *, 2, 3,1,^,1,2,9,*,/,4,2,3

      Answer : 0  (zero)

   


Linked List representation of polynomial

you can find solution here.






Feel free to  ask any questions, i will try to update solution here. for solutions visit my blog regularly.











No comments:

Post a Comment