Font size
WorksheetsQuiz2-DSA-FCPC
Total questions: 40
Worksheet time: 40mins
A web browser maintains a history of visited pages. When you press the “Back” button, the browser retrieves the last page you visited. Which data structure best models this behavior?
Queue
Stack
Linked List
Tree
A printer receives multiple print requests from users. It processes the first request received before the rest. Which structure is most suitable?
Stack
Queue
Heap
Tree
A recursive function for factorial(5) calls itself until n == 1. How many total calls are made?
A. 4
B. 5
C. 6
D. Infinite
In a customer service line, the first customer is served first. This behavior follows:
LIFO
FIFO
FILO
LILO
A recursive function without a base case will result in:
Logical error
Stack overflow
Queue overflow
Compilation error
During function execution, the system stores return addresses and local variables in a:
Queue
Stack
Heap
Array
A hospital triage system prioritizes patients based on severity instead of arrival order. Which structure is not suitable?
Priority Queue
Simple Queue
Heap
Stack
The recursive Fibonacci algorithm is inefficient because:
It uses too many global variables
It re-computes subproblems repeatedly
It lacks parameters
When pushing elements onto a full stack, the error encountered is called:
Underflow
Overflow
Deadlock
Exception
Which of the following operations is not possible in a queue?
Enqueue at front
Dequeue from front
Enqueue at rear
Peek front element
A palindrome checker using a stack compares characters in what order?
Left to right
Randomly
Reverse order
First and last alternately
In a call stack, each new function call is added to:
Bottom of the stack
Top of the stack
A queue implemented with two stacks performs enqueue by:
Pushing onto stack 1
Popping from stack 2
Reversing stack 1
Using recursion
Which of the following is an application of recursion?
Searching a file
Traversing a directory tree
Sorting numbers iteratively
Managing user input
When a queue is implemented as a circular queue, which problem is avoided?
Overflow
Underflow
Wasted memory space
Reversing order
A recursive function that computes the sum of digits of 1234 returns:
A. 10
B. 1234
C. 7
D. 8
Which structure would best handle the undo feature in a text editor?
Queue
Stack
Array
Linked list
A stack follows the First In First Out (FIFO) principle.
True
False
Recursion always requires a base case to prevent infinite calls.
True
False
A queue can be used to implement recursion.
True
False
In a stack, the pop() operation removes the most recently added element.
True
False
Tail recursion is a type of recursion that can be optimized by the compiler.
True
False
A circular queue automatically wraps around when it reaches the end of the array.
True
False
The factorial of zero (0!) equals one, even in recursive implementation.
True
False
A recursive function always performs faster than an iterative one.
True
False
Queue underflow occurs when trying to enqueue to a full queue.
True
False
The call stack keeps track of function calls and their local variables.
True
False
The data structure used to reverse a string is called a __________.
Stack
Queue
Array
Linked List
In recursion, the point where the function stops calling itself is called the __________.
Base case
Recursive step
Loop condition
Exit value
The two main operations in a queue are __________ and __________.
Enqueue, Dequeue
Push, Pop
Insert, Delete
Add, Remove
When a stack is empty and a pop operation is attempted, it causes a __________ error.
Underflow
Overflow
Syntax
Runtime
The function call mechanism in most programming languages uses a __________ internally.
Stack
Queue
Array
Linked List
The process of one function calling itself directly or indirectly is called __________.
Recursion
Iteration
Abstraction
Polymorphism
In a circular queue, the rear pointer wraps around to the __________ of the array.
Front
End
Middle
Last
The operation that adds an element at the rear end of a queue is called __________.
Enqueue
Dequeue
Pop
Peek
A stack that grows beyond its maximum limit results in a __________ error.
Stack overflow
Heap underflow
Segmentation fault
Buffer underrun
A parking garage allows cars to leave only in reverse order of entry. Which data structure models this?
(a)
The recursive approach to solving problems works by breaking a problem into (a) of itself until a base case is reached.
A recursive function that calls itself directly is called (a) recursion, while one that calls another function that then calls it back is called indirect recursion.
The (a) of recursion refers to the number of times a function can call itself before reaching the base case.
