Data Structures & AlgorithmsEasyTCS NQT · Wipro pattern
An empty deque performs push_front(1), push_front(2), push_front(3) and then pop_back(). Which value is removed?
- A. 3
- B. 2
- C. 1
- D. The deque is empty
Correct answer: C. 1
After three push_front calls the deque reads 3, 2, 1 from front to back. pop_back removes from the back, which is the first value pushed: 1. '3' would be pop_front.
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 holds n elements and has spare capacity. What is the worst-case time to insert a new element so that the array stays sorted?
- Counting sort on [2, 0, 2, 1, 0, 2] (values 0–2) builds count[v] and then turns it into cumulative counts, count[v] = number of elements ≤…
- Two pointers start at both ends of the sorted array [1, 3, 4, 6, 8, 11] to find pairs of DIFFERENT positions with sum 12 (move left if the…
- A hash map starts with capacity 16 and doubles its capacity whenever the number of keys EXCEEDS 0.75 × capacity. What is its capacity…
- Bubble sort (each pass compares adjacent pairs left to right and swaps if out of order) runs on [6, 2, 9, 1, 5]. What is the array after…
- The array [1, 2, 3, 4, 5, 6] is first rotated RIGHT by 2 positions and then rotated LEFT by 5 positions. What is the result?