Question 41
MediumWhat is the prefix form of (A − B) * (C + D)?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What is the prefix form of (A − B) * (C + D)?
− * A B + C D
A B − C D + *
Sign up free to see the answer and a step-by-step explanation.
What is the value of the prefix expression + * 2 3 4?
10
14
20
9
Sign up free to see the answer and a step-by-step explanation.
The pushes are 1, 2, 3, 4 in that order, with pops allowed in between. Which pop order is impossible?
4, 1, 2, 3
1, 2, 3, 4
3, 2, 4, 1
2, 1, 4, 3
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of converting an infix expression of n tokens to postfix with a stack?
O(n log n)
O(log n)
O(n²)
O(n)
Sign up free to see the answer and a step-by-step explanation.
Which problem is solved with a monotonic stack?
Stock span (days since a higher price)
Matrix multiplication
Shortest path
Binary search
Sign up free to see the answer and a step-by-step explanation.
A recursive function calls itself 10,000 levels deep. What might happen?
Stack overflow, because each call uses stack space
A heap overflow
Nothing; recursion has no limit
The function runs faster
Sign up free to see the answer and a step-by-step explanation.
Which is the best data structure to implement 'undo' in a text editor?
A queue
A stack
A hash map
A heap
Sign up free to see the answer and a step-by-step explanation.
How does an array-based stack detect overflow?
The array becomes sorted
top reaches the array's capacity − 1 before a push
top becomes −1
It cannot
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of each operation of a stack implemented with a linked list?
O(log n) for pop
O(1) for push, pop and peek
O(n) for peek
O(n) for push
Sign up free to see the answer and a step-by-step explanation.
Which algorithm uses an explicit stack to traverse a graph?
Breadth-first search
Prim's algorithm
Dijkstra's algorithm
Iterative depth-first search
Sign up free to see the answer and a step-by-step explanation.