wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz2-DSA-FCPC

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

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?

a)

Queue

b)

Stack

c)

Linked List

d)

Tree

2.

A printer receives multiple print requests from users. It processes the first request received before the rest. Which structure is most suitable?

a)

Stack

b)

Queue

c)

Heap

d)

Tree

3.

A recursive function for factorial(5) calls itself until n == 1. How many total calls are made?

a)

A. 4

b)

B. 5

c)

C. 6

d)

D. Infinite

4.

In a customer service line, the first customer is served first. This behavior follows:

a)

LIFO

b)

FIFO

c)

FILO

d)

LILO

5.

A recursive function without a base case will result in:

a)

Logical error

b)

Stack overflow

c)

Queue overflow

d)

Compilation error

6.

During function execution, the system stores return addresses and local variables in a:

a)

Queue

b)

Stack

c)

Heap

d)

Array

7.

A hospital triage system prioritizes patients based on severity instead of arrival order. Which structure is not suitable?

a)

Priority Queue

b)

Simple Queue

c)

Heap

d)

Stack

8.

The recursive Fibonacci algorithm is inefficient because:

a)

It uses too many global variables

b)

It re-computes subproblems repeatedly

c)

It lacks parameters

9.

When pushing elements onto a full stack, the error encountered is called:

a)

Underflow

b)

Overflow

c)

Deadlock

d)

Exception

10.

Which of the following operations is not possible in a queue?

a)

Enqueue at front

b)

Dequeue from front

c)

Enqueue at rear

d)

Peek front element

11.

A palindrome checker using a stack compares characters in what order?

a)

Left to right

b)

Randomly

c)

Reverse order

d)

First and last alternately

12.

In a call stack, each new function call is added to:

a)

Bottom of the stack

b)

Top of the stack

13.

A queue implemented with two stacks performs enqueue by:

a)

Pushing onto stack 1

b)

Popping from stack 2

c)

Reversing stack 1

d)

Using recursion

14.

Which of the following is an application of recursion?

a)

Searching a file

b)

Traversing a directory tree

c)

Sorting numbers iteratively

d)

Managing user input

15.

When a queue is implemented as a circular queue, which problem is avoided?

a)

Overflow

b)

Underflow

c)

Wasted memory space

d)

Reversing order

16.

A recursive function that computes the sum of digits of 1234 returns:

a)

A. 10

b)

B. 1234

c)

C. 7

d)

D. 8

17.

Which structure would best handle the undo feature in a text editor?

a)

Queue

b)

Stack

c)

Array

d)

Linked list

18.

A stack follows the First In First Out (FIFO) principle.

a)

True

b)

False

19.

Recursion always requires a base case to prevent infinite calls.

a)

True

b)

False

20.

A queue can be used to implement recursion.

a)

True

b)

False

21.

In a stack, the pop() operation removes the most recently added element.

a)

True

b)

False

22.

Tail recursion is a type of recursion that can be optimized by the compiler.

a)

True

b)

False

23.

A circular queue automatically wraps around when it reaches the end of the array.

a)

True

b)

False

24.

The factorial of zero (0!) equals one, even in recursive implementation.

a)

True

b)

False

25.

A recursive function always performs faster than an iterative one.

a)

True

b)

False

26.

Queue underflow occurs when trying to enqueue to a full queue.

a)

True

b)

False

27.

The call stack keeps track of function calls and their local variables.

a)

True

b)

False

28.

The data structure used to reverse a string is called a __________.

a)

Stack

b)

Queue

c)

Array

d)

Linked List

29.

In recursion, the point where the function stops calling itself is called the __________.

a)

Base case

b)

Recursive step

c)

Loop condition

d)

Exit value

30.

The two main operations in a queue are __________ and __________.

a)

Enqueue, Dequeue

b)

Push, Pop

c)

Insert, Delete

d)

Add, Remove

31.

When a stack is empty and a pop operation is attempted, it causes a __________ error.

a)

Underflow

b)

Overflow

c)

Syntax

d)

Runtime

32.

The function call mechanism in most programming languages uses a __________ internally.

a)

Stack

b)

Queue

c)

Array

d)

Linked List

33.

The process of one function calling itself directly or indirectly is called __________.

a)

Recursion

b)

Iteration

c)

Abstraction

d)

Polymorphism

34.

In a circular queue, the rear pointer wraps around to the __________ of the array.

a)

Front

b)

End

c)

Middle

d)

Last

35.

The operation that adds an element at the rear end of a queue is called __________.

a)

Enqueue

b)

Dequeue

c)

Pop

d)

Peek

36.

A stack that grows beyond its maximum limit results in a __________ error.

a)

Stack overflow

b)

Heap underflow

c)

Segmentation fault

d)

Buffer underrun

37.

A parking garage allows cars to leave only in reverse order of entry. Which data structure models this?

(a)  

38.

The recursive approach to solving problems works by breaking a problem into (a)   of itself until a base case is reached.

39.

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.

40.

The (a)   of recursion refers to the number of times a function can call itself before reaching the base case.