Q. In a circular queue, what happens when the rear pointer reaches the end of the array?
-
A.
It resets to the beginning of the array
-
B.
It stops accepting new elements
-
C.
It throws an error
-
D.
It moves to the next available position
Solution
In a circular queue, when the rear pointer reaches the end of the array, it resets to the beginning of the array to utilize the available space.
Correct Answer:
A
— It resets to the beginning of the array
Learn More →
Q. What is the main advantage of using a stack for function calls?
-
A.
It allows for dynamic memory allocation
-
B.
It provides a way to manage local variables
-
C.
It enables recursion
-
D.
It improves performance
Solution
Stacks are used for function calls because they enable recursion by keeping track of the return addresses and local variables.
Correct Answer:
C
— It enables recursion
Learn More →
Q. What is the result of popping an element from an empty stack?
-
A.
The top element is returned
-
B.
An error is thrown
-
C.
The stack remains unchanged
-
D.
The stack is cleared
Solution
Popping an element from an empty stack typically results in an error being thrown, as there are no elements to remove.
Correct Answer:
B
— An error is thrown
Learn More →
Q. Which data structure would you use to implement a breadth-first search (BFS)?
-
A.
Stack
-
B.
Queue
-
C.
Linked List
-
D.
Array
Solution
A queue is used to implement breadth-first search (BFS) because it processes nodes in the order they are discovered.
Correct Answer:
B
— Queue
Learn More →
Showing 1 to 4 of 4 (1 Pages)