Data Structures & AlgorithmsEasyTCS NQT · Wipro pattern
An empty queue performs: enqueue 7, enqueue 2, enqueue 9, dequeue, enqueue 4, dequeue. Which element is now at the front?
- A. 9
- B. 4
- C. 2
- D. 7
Correct answer: A. 9
FIFO: the two dequeues remove 7 and then 2 (the two oldest items). The queue is now 9, 4 with 9 at the front. '4' is the stack (LIFO) answer: the most recently added item.
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
- In a doubly linked list you are given a pointer to a node X somewhere in the middle. What is the time to delete X?
- A hash table has 7 slots and uses h(k) = k mod 7. In which slot is the key 50 placed if that slot is empty?
- Operators have the usual precedence ( and / above + and −, all left-associative). What is the postfix form of A (B + C) / D − E?
- What is the value of the prefix expression + 3 4 − 9 / 8 2 ?
- Selection sort (find the minimum of the unsorted part, swap it to the front only if it is not already there) sorts [29, 10, 14, 37, 13]…
- Binary search with mid = (lo + hi) / 2 (integer division) looks for 31 in [3, 9, 14, 20, 27, 31, 40] (0-based). Which indices are probed…