Data Structures & AlgorithmsEasyWipro · Accenture pattern
Which of these is NOT a typical application of a stack?
- A. Managing function calls (call stack)
- B. Breadth-first search of a graph
- C. Undo in a text editor
- D. Checking balanced parentheses
Correct answer: B. Breadth-first search of a graph
BFS visits vertices level by level and needs a FIFO queue. Parenthesis matching, the call stack and undo all need the most recent item first, which is what a stack provides.
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
- 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…
- The numbers 1, 2, 3, 4, 5 are pushed onto a stack in that order, and pops may happen at any time in between. Which output sequence is…
- Keys 15, 11, 27, 8, 12, 22, 29, 1 are inserted into a hash table of size 7 with h(k) = k mod 7 and separate chaining. What is the length…
- Keys 22, 33 and 44 are inserted in that order into an empty table of size 11 with h(k) = k mod 11 and quadratic probing hᵢ(k) = (h(k) +…
- Two sorted lists of 5 and 7 elements are merged by the standard merge procedure. What is the maximum number of comparisons it can make?
- A fixed-size sliding window of length 3 moves over [2, 1, 5, 1, 3, 2, 9, 1]. What is the largest window sum?