AMCAT Basic Data Structures 3 — Questions and Answers
Question 1: Which operation is used to remove an element from the front of a queue?
- Push
- Pop
- Dequeue (Correct answer)
- Peek
Correct answer: Dequeue
Dequeue (also called dequeue or poll) removes and returns the front element of a queue.
Question 2: A stack implemented using an array of size N can hold at most how many elements before overflow occurs?
- N-1
- N (Correct answer)
- N+1
- 2N
Correct answer: N
An array-based stack of size N can hold exactly N elements before a stack overflow condition.
Question 3: What does the 'peek' (or 'top') operation on a stack return?
- Removes and returns the top element
- Returns the top element without removing it (Correct answer)
- Returns the bottom element
- Returns the size of the stack
Correct answer: Returns the top element without removing it
Peek inspects the top element of the stack without modifying the stack.
Question 4: Which abstract data type is most appropriate for implementing a print spooler?
- Stack
- Queue (Correct answer)
- Priority Queue
- Deque
Correct answer: Queue
A print spooler processes jobs in the order they arrive (FIFO), making a queue the natural choice.
Question 5: In a deque (double-ended queue), insertions and deletions can occur at:
- Only the front
- Only the rear
- Both front and rear (Correct answer)
- Any arbitrary position
Correct answer: Both front and rear
A deque allows insertions and deletions at both the front and rear ends.
Question 6: When evaluating a postfix expression using a stack, what happens when an operand is encountered?
- It is immediately evaluated
- It is pushed onto the stack (Correct answer)
- It is discarded
- It pops two elements from the stack
Correct answer: It is pushed onto the stack
In postfix evaluation, operands are pushed onto the stack; operators pop operands and push results.
Question 7: Which of the following queue variants gives highest-priority elements access before lower-priority ones regardless of arrival order?
- Circular Queue
- Double-ended Queue
- Priority Queue (Correct answer)
- Simple Queue
Correct answer: Priority Queue
A priority queue dequeues elements based on assigned priority, not insertion order.
Which operation is used to remove an element from the front of a queue?