wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

QUIZ-3

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

What is recursion?

a)

A. A function calling itself

b)

B. A loop inside another loop

c)

C. A function that returns another function

d)

D. A function that never terminates

2.

What happens if a recursive function has no base condition?

a)

A. Program runs faster

b)

B. Program stops automatically

c)


C. Infinite recursion → stack overflow

d)

D. Output becomes zero

3.

Which of the following best explains why the Fibonacci program becomes slow for large input values?

a)

A. Because recursion is not allowed in C

b)

B. Because each function call stores its value in a global array

c)

C. Because multiple recursive calls recompute the same subproblems

d)

D. Because printf() delays execution

4.

For a Tower of Hanoi problem with n disks, what is the total number of moves made by the program?

a)

A. n²

b)

B. 2ⁿ

c)

C. 2ⁿ − 1

d)

D. n!

5.

What is a queue in data structures?

a)

A. A structure where the last inserted element is removed first

b)

B. A linear data structure that follows FIFO (First In First Out)

c)

C. A structure used only for tree traversal

d)

D. A structure where insertion and deletion happen at the same end

6.

Which of the following operations may lead to unused empty space in the queue?

a)

A. insert() only

b)

B. rem() only

c)


C. A combination of insert() and rem()

d)

D. display()

7.

If f = 2 and r = 4, what is the maximum number of elements remaining in the queue?

a)

A. 2

b)

B. 3

c)

C. 4

d)

D. 5

8.

After performing the operations Insert(5), Insert(10), Insert(15), Remove(), Insert(20), what are the values of f and r?

a)

A. f = 0, r = 2

b)

B. f = 1, r = 3

c)

C. f = 1, r = 2

d)

D. f = 2, r = 3

9.

What will be printed by display() if f=2, r=4 and q = {10,20,30,40,50}?

a)

A 10 20

b)

B. 30 40 50

c)

C. 20 30 40 50

d)

D. Nothing

10.

Consider the following code snippet from the Queue program:

if(r == MAX-1) {

printf("Queue is full"); return; }

What condition is this checking?

a)

A. Underflow condition

b)

B. Overflow condition

c)

C. Queue is empty

d)

D. Queue has only one element

11.

Look at this deletion code snippet:

if(f == r) f = r = -1;

else f = f + 1;

What does the line f = r = -1 represent?

a)

A. Queue is full

b)

B. Queue contains one element, and it was deleted

c)

C. Queue needs to be sorted

d)

D. New element inserted at front

12.

What is the logical error here?

for(int i = r; i >= f; i--) printf("%d ", q[i]);

a)

A. It prints queue in FIFO order

b)

B. It prints queue in reverse order (wrong behavior)

c)

C. It deletes elements

d)

D. It causes overflow

13.

In a circular queue, the queue is considered full when:

a)

A. f == r

b)

B. (r + 1) % MAX == f

c)

C. f == -1

d)

D. r == -1

14.

The initial values of front (f) and rear (r) in the given program are:

a)

A. f = 0, r = 0

b)

B. f = 1, r = 1

c)

C. f = -1, r = -1

d)

D. f = MAX

15.

The delete operation prints which message when the queue is empty?

a)

A. "cq is full"

b)

B. "deleted item"

c)

C. "cq is empty"

d)

D. "invalid choice"

16.

What condition resets both f and r to -1 during deletion?

a)

A. When queue is full

b)

B. When f == r

c)

C. When f == -1

d)

D. When user enters invalid choice

17.

In the display() function, the queue is printed until:

a)

A. i == f

b)

B. i == -1

c)

C. i != r

d)

D. i == MAX

18.

The insert() function uses which formula to update rear (r)?

a)

A. r++

b)

B. r = (r - 1) % MAX

c)

C. r = (r + 1) % MAX

d)

D. r = MAX - 1

19.

Why is the input format for reading a character in insert() written as scanf(" %c",&e); with a space before %c?

a)

A. To skip leading whitespaces/newlines

b)

B. To restrict input to alphabets only

c)

C. To convert char to ASCII

d)

D. To avoid overflow

20.

while (i != r) {

printf("%c ", cq[i]);

i = (i + 1);

}

What is the bug?

a)

A. Missing semicolon

b)

B. i = (i + 1); must be i = (i + 1) % MAX

c)

C. Condition must be i == r

d)

D. Array index must start at 1