Data Structures & AlgorithmsModerateTCS Digital · Infosys SP
Which application does NOT naturally use a stack?
- A. Evaluating a postfix expression
- B. Breadth-first traversal of a graph
- C. Checking balanced parentheses
- D. Undo in a text editor
Correct answer: B. Breadth-first traversal of a graph
BFS processes vertices level by level, which needs a FIFO queue. Undo, postfix evaluation and bracket matching are all last-in-first-out.
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
- Two numbers are stored as linked lists with digits in REVERSE order (units first). What does this addition print? python def add(a, b): d…
- How many contiguous subarrays of [5, 4, 4, 3, 2, 5, 2, 2] have a sum between 7 and 11 inclusive? (All values positive: count atMost(11) −…
- KMP failure function (lps[i] = length of the longest proper prefix of p[0..i] that is also a suffix). What is printed? python def lps(p)…
- Two numbers are stored as linked lists with digits in REVERSE order (units first). What does this addition print? python def add(a, b): d…
- A monotonic deque reports the maximum of every window of size 3 in [14, 5, −3, 14, 5, 14, −5, 16, 4]. What is the SUM of all reported…
- Delete duplicates from a SORTED linked list. Version A keeps one copy of each value; version B removes every value that appears more than…