GATE Computer ScienceEasyGATE CS (PYQ pattern)
Evaluate the postfix expression 9 3 - 4 2 * 5 - 7 3 / * + where / is integer division truncating toward zero.
- A. 15
- B. 10
- C. 18
- D. 12
Correct answer: D. 12
9 3 - = 6; 4 2 * = 8, 8 5 - = 3; 7 3 / = 2; 3 * 2 = 6; finally 6 + 6 = 12. A careless pop order (y before x) on - or / changes this.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- Ten people numbered 1 to 10 stand in a circle (a circular linked list in increasing order). Counting starts at person s, who is counted as…
- A singly linked list has 17 nodes numbered 0 to 16 from the head; node 16 points back to node 7 (so the tail of length 7 leads into a…
- A routine rev(k) reverses every block of k consecutive nodes of a singly linked list in place, leaving a final block of fewer than k nodes…
- A queue is built from two stacks: enqueue pushes onto stack IN; dequeue pops from OUT, and if OUT is empty it first moves every element of…
- A BST is built by inserting 50, 30, 70, 20, 40, 60, 80 in some order into an initially empty tree. The final tree is the perfectly…
- Insert 45, 25, 65, 15, 35, 55, 75, 10, 20, 30, 40, 50, 60 into an empty BST. Then delete 25, 45 and 65 in that order, replacing a node…