Data Structures & AlgorithmsModerateWipro · Accenture pattern
What is the value of the postfix expression 6 2 3 + − 3 8 2 / + * ?
- A. -7
- B. 49
- C. 7
- D. 1
Correct answer: C. 7
2 3 + = 5; 6 − 5 = 1; 8 2 / = 4; 3 + 4 = 7; finally 1 × 7 = 7. Popping the operands in the wrong order gives 5 − 6 = −1 and hence −7.
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
- A circular queue is implemented in an array of size 10 and one slot is always kept empty so that 'full' and 'empty' can be told apart. How…
- Keys 23, 43, 13 and 27 are inserted in that order into an empty hash table of size 10 with h(k) = k mod 10 and linear probing. At which…
- For A = [3, 1, 4, 1, 5, 9, 2, 6] (0-based), the prefix array is P[0] = 0 and P[i] = A[0] + … + A[i−1]. Which expression gives the sum A[2]…
- Linear search looks for a key that is NOT in an unsorted array of 100 elements. How many key comparisons does it make?
- What is the minimum number of stacks needed to implement a queue, if no other data structure may be used?
- What is the prefix (Polish) form of (A + B) (C − D)?