Q. In a stack implemented using an array, what happens when you try to push an element onto a full stack?
-
A.
The element is added
-
B.
The stack overflows
-
C.
The stack shrinks
-
D.
The element is ignored
Solution
Pushing onto a full stack results in a stack overflow error, as there is no space to add more elements.
Correct Answer:
B
— The stack overflows
Learn More →
Q. In which scenario would you prefer a queue over a stack?
-
A.
When you need to access the last element
-
B.
When you need to process elements in the order they were added
-
C.
When you need to delete elements randomly
-
D.
When you need to access elements by index
Solution
A queue is preferred when you need to process elements in the order they were added, following the First In First Out (FIFO) principle.
Correct Answer:
B
— When you need to process elements in the order they were added
Learn More →
Showing 1 to 2 of 2 (1 Pages)