Q. What is the time complexity of popping an element from a queue implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Solution
Popping an element from a queue implemented using a linked list can be done in constant time, O(1), if we maintain a pointer to the front of the queue.
Q. Which data structure would you use to implement a function call stack?
A.
Queue
B.
Array
C.
Stack
D.
Linked List
Solution
A stack is used to implement a function call stack because it follows the LIFO principle, allowing the most recent function call to be completed first.