Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE
Evaluate the postfix expression: 8 8 2 + * 3 1 + 8 + *
- A. 1152
- B. -960
- C. 960
- D. 768
Correct answer: C. 960
Scan left to right with a stack: on an operator pop b then a and push a op b (note the order for −). Result 960.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many swaps does bubble sort (adjacent swaps, ascending) make on [44, 48, 59, 38, 4, 32, 49]?
- A sorted array holds the 15 values 2, 5, 8, … (step 3). Binary search with mid = ⌊(lo+hi)/2⌋ and 0-based indices looks for 11. How many…
- Keys 76, 92, 75, 39, 73, 79, 41, 56, 14 are inserted into a hash table of size 11 with h(k) = k mod 11 and linear probing. At which index…
- A circular queue is implemented in an array of size 10 with front = 6 and rear = 6 (rear indexes the last stored element, the queue is…
- Two sorted lists [6, 8, 12, 35] and [4, 11, 17, 20, 25, 29] are merged using the standard merge step. How many element comparisons are made?
- Evaluate the postfix expression: 4 3 5 + 3 -