Data Structures & AlgorithmsModerateWipro · Accenture pattern
What is the postfix form of (A + B) * C − (D − E) * (F + G)?
- A. A B C + * D E − F G + * −
- B. A B + C * D E − − F G + *
- C. A B + C * D E − F G + * −
- D. A B + C D E − * F G + * −
Correct answer: C. A B + C * D E − F G + * −
Left operand of the main −: (A + B) * C → A B + C *. Right operand: (D − E) * (F + G) → D E − F G + *. Then the − goes last.
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
- What is the value of the prefix expression − + 2 3 4 / 8 2 ?
- Infix A (B + C (D − E)) / F is converted to postfix with an operator stack (operators and '(' are pushed onto it). What is the largest…
- Using a sliding window, find the length of the longest substring with no repeated character in the string dvdfabcda.
- What is the length of the shortest contiguous subarray of [1, 4, 4, 2, 3, 1, 5] whose sum is at least 9?
- How many contiguous subarrays of [1, 2, 3, −3, 3, 1] have sum exactly 3? (A prefix-sum + hash-map method counts them in O(n).)
- How many UNIQUE triplets (as sets of values, ignoring order) of [−1, 0, 1, 2, −1, −4, −2, 3] sum to 0? (Sort + two pointers, skipping…