Q. What is the main disadvantage of using a stack for function call management?
A.
Limited size
B.
Slow access
C.
Complex implementation
D.
No recursion support
Solution
The main disadvantage of using a stack for function call management is its limited size, which can lead to stack overflow if too many function calls are made.
Q. What is the time complexity of pushing an element onto a stack implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Solution
Pushing an element onto a stack implemented using a linked list takes constant time, O(1), because it involves adding a new node at the head of the list.
Q. Which data structure is best suited for implementing a function that reverses a string?
A.
Queue
B.
Stack
C.
Linked List
D.
Array
Solution
A stack is best suited for reversing a string because it follows the Last In First Out (LIFO) principle, allowing the last character pushed to be the first one popped.