Algorithms Technology & Digital Applications 4 — Questions and Answers
Question 1: A web browser maintains a Back button history. Pressing Back retrieves the previous page. Which abstract data type models this?
- Queue
- Stack (Correct answer)
- Deque
- Priority Queue
Correct answer: Stack
A stack's LIFO (last-in, first-out) behavior perfectly models browser history where the most recently visited page is retrieved first.
Question 2: A printer queues jobs and processes them in the order they arrive. Which data structure models the print queue?
- Stack
- Binary Search Tree
- Queue (Correct answer)
- Graph
Correct answer: Queue
A queue's FIFO (first-in, first-out) property ensures print jobs are processed in the order they were submitted.
Question 3: A network router decides which packet to forward next based on the highest priority flag. What data structure should the router use?
- Stack
- Queue
- Priority Queue (Heap) (Correct answer)
- Trie
Correct answer: Priority Queue (Heap)
A priority queue (implemented as a heap) allows the router to always dequeue the highest-priority packet in O(log n) time.
Question 4: A programming language runtime tracks function calls so it can return to the correct caller. What does it use?
- Heap memory
- Call stack (Correct answer)
- Hash map
- Adjacency list
Correct answer: Call stack
The call stack stores return addresses and local variables, ensuring functions resume at the correct point after returning.
Question 5: A distributed system processes tasks as soon as workers become free, regardless of submission order. Which queue variant is most appropriate?
- FIFO Queue
- LIFO Stack
- Work-stealing deque (Correct answer)
- Circular buffer
Correct answer: Work-stealing deque
Work-stealing deques let idle workers steal tasks from busy workers' queues, balancing load dynamically in distributed systems.
Question 6: An undo feature in a drawing app lets users redo actions after undoing them. Which data structure combination supports both undo and redo?
- Two stacks (Correct answer)
- One queue
- A priority queue
- A circular buffer
Correct answer: Two stacks
Two stacks, one for undo history and one for redo history, efficiently support both operations with O(1) push and pop.
Question 7: A hospital emergency room processes patients by severity, not arrival time. Which algorithmic structure best models this?
- FIFO Queue
- Stack
- Priority Queue (max-heap) (Correct answer)
- Singly linked list
Correct answer: Priority Queue (max-heap)
A max-heap priority queue retrieves the highest-priority (most severe) patient in O(log n) time regardless of arrival order.
A web browser maintains a Back button history.
Pressing Back retrieves the previous page.
Which abstract data type models this?