Data Structures & AlgorithmsHardTCS NQT · Infosys
Evaluate the Reverse Polish expression 10 6 9 3 + -11 * / * 17 + 5 +. What is the result?
- A. 23
- B. 24
- C. 26
- D. 22
Correct answer: D. 22
Operands are pushed; each operator pops two and pushes the result. The intermediate values are 12, then -132, then 6 / -132 truncates to 0, so the product is 0; the final additions give 22.
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 integers x in [1, 1000] have exactly 4 positive divisors?
- How many integers n with 1 <= n <= 200 have exactly 6 trailing zeros in n! (written in base 10)?
- What is the sum of all integers in [1, 100] whose digit sum is prime?
- A snail climbs a well of height 10 metres. Each day it climbs 3 metres; each night it slides back 2 metres. It stops when it first reaches…
- Starting at n = 7, repeat: if n is even replace n by n/2, otherwise replace n by 3n + 1. How many steps are needed to reach 1?
- What is the total number of comparisons made by insertion sort on the array [3, 1, 4, 1, 5] (each test of a[j-1] > a[j] counts as one…