Q17. Evaluate the following Postfix expression using stack. Show each and every step of stack during evaluation.
, where a=7; b=3; c=12; d=-5; e=1.
Q18. Convert the following infix expression to prefix expression.
(i)
2 + 3
(ii)
(2 + 3) - 5
(iii)
5 * ((6 + 2) - 4)
(iv)
(2 * 3) / ((4 + 6) * (9 - 4))
(v)
( 15 + 2 $ 3 $ 2 / (4 * ( 7 – 6 ) * ( 4 / 4)))
(vi)
4 + ( ( 15 + 2 $ 3 $ 2 / ( 4 * ( 7 – 6 ) * ( 4 / 4 ) ) ) * 2)
(vii)
4 + 15 + 2 $ 3 $ 2 / 4 * 7 – 6 * 4 / 4 * 2
Assignment 8
Q18. Convert the following infix expression to postfix expression.
(i)2 + 3
(ii)(2 + 3) - 5
(iii)5 * ((6 + 2) - 4)
(iv)(2 * 3) / ((4 + 6) * (9 - 4))
(v)( 15 + 2 $ 3 $ 2 / (4 * ( 7 – 6 ) * ( 4 / 4)))
(vi)4 + ( ( 15 + 2 $ 3 $ 2 / ( 4 * ( 7 * 6 ) * ( 4 / 4 ) ) ) * 2 )
(vii)4 + 15 + 2 $ 3 $ 2 / 4 * 7 – 6 * 4 / 4 * 2
Assignment 9
Q19. Given an expression involving three different pairs of paranthesis "(", ")", "{", "}", "[" and "]" and other terms such as variable names and integers, the problem is to determine if the expression is well formed with respect to parentheses.
For example, the expression " a ( b * c ) - { ( c ^ d ) / g } " is well formed.
The expression, " a ( b * ) c ) - { ( c ^ d } / g )" is not well formed it has many unbalanced parenthesis in it.
Assignment 10
Q20. Sort the following list of numbers
8, 9, 3, 5, 6, 4, 2, 1, 7, 0
(i) Insertion Sort
(ii)Selection Sort
(iii)Bubble Sort
Show each step of sorting.
Q21. Write a program to implement stack using linked list.
Q22. Write a program to implement queue using arrays.
Q23. Write a program to implement queue using Linked List.
Q24. Write a program to implement circular queue using arrays.
Q25. Write a program to implement circular queue using linked list and double Linked List.