Data Structures & AlgorithmsModerateCognizant · Capgemini pattern
What is the prefix (Polish) form of (A + B) * (C − D)?
- A. * + A B − C D
- B. * A B + − C D
- C. A B + C D − *
- D. + A B * − C D
Correct answer: A. * + A B − C D
The last operator applied is *, so it comes first, followed by the prefix forms of its two operands: + A B and − C D. A B + C D − * is the postfix form.
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
- Bubble sort is written with a flag that stops it when a full pass makes no swap. What is its time complexity on an array that is already…
- Kadane's algorithm is run on [3, −4, 5, −1, 2, −6, 4]. What maximum contiguous subarray sum does it return?
- What is the auxiliary space used by the standard top-down merge sort on an array of n elements?
- In a singly linked list you are given only a pointer to a node X (not the last node) and no head pointer. How can X be deleted, and in…
- Which of these is NOT a typical application of a stack?
- A sorted array of n integers is given. Using the two-pointer technique, what are the time and extra space needed to decide whether some…