Q. In a queue, what operation is used to remove an element?
-
A.
Push
-
B.
Pop
-
C.
Enqueue
-
D.
Dequeue
Solution
The operation used to remove an element from a queue is called 'Dequeue'.
Correct Answer:
D
— Dequeue
Learn More →
Q. What is the worst-case time complexity for searching an element in an unsorted stack?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
The worst-case time complexity for searching an element in an unsorted stack is O(n), as you may need to check each element.
Correct Answer:
B
— O(n)
Learn More →
Q. Which data structure would you use to implement a recursive algorithm iteratively?
-
A.
Array
-
B.
Linked List
-
C.
Stack
-
D.
Queue
Solution
A stack is used to implement a recursive algorithm iteratively, as it can keep track of function calls and local variables.
Correct Answer:
C
— Stack
Learn More →
Q. Which of the following is NOT a typical application of stacks?
-
A.
Function call management
-
B.
Expression evaluation
-
C.
Backtracking algorithms
-
D.
Breadth-first search
Solution
Breadth-first search (BFS) typically uses a queue, not a stack, as it explores nodes level by level.
Correct Answer:
D
— Breadth-first search
Learn More →
Q. Which of the following operations is not supported by a queue?
-
A.
Enqueue
-
B.
Dequeue
-
C.
Peek
-
D.
Pop
Solution
The 'Pop' operation is not supported by a queue; it is associated with stacks. Queues use 'Enqueue' to add and 'Dequeue' to remove elements.
Correct Answer:
D
— Pop
Learn More →
Showing 1 to 5 of 5 (1 Pages)