Data Structures & AlgorithmsHardTCS Digital · Infosys SP
^ is exponentiation (highest precedence, right-associative); * and / come next; + and − are lowest; others are left-associative. What is the prefix (Polish) form of A + B ^ (C ^ D) ^ E / F?
- A. +ABCD^E^^F/
- B. +A/^B^C^DEF
- C. +A/^B^^CDEF
- D. +/F^^E^DCBA
Correct answer: C. +A/^B^^CDEF
Build the expression tree respecting precedence and parentheses, then write it root-first. Reversing the postfix string is a common trap — it also reverses operand order.
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
- Selection sort (ascending; in pass i find the minimum of the unsorted part and swap it into position i only if it is not already there) is…
- Only the lower triangle (including the diagonal) of a 12 × 12 matrix is stored row by row in a 1-D array B starting at B[0] (indices…
- Count palindromic substrings by expanding around all 2n − 1 centres, and also count DISTINCT palindromic substrings. What is printed?…
- You need to sort 10⁷ integers, each in the range 0 to 999. Which approach is asymptotically fastest?
- Count pairs with a given difference k (k > 0) among DISTINCT values using a hash set. What is printed? python a, k = [8, 7, 7, 10, 5, 11…
- Why is a tombstone (a 'deleted' marker) used instead of emptying a slot when deleting from an open-addressing hash table?