Q. In which scenario would a linked list be preferred over an array?
A.
When the size of the data is known
B.
When frequent insertions and deletions are required
C.
When random access is needed
D.
When memory is limited
Solution
Linked lists are preferred when frequent insertions and deletions are required because they can be done in O(1) time, unlike arrays which require O(n) time.
Correct Answer:
B
— When frequent insertions and deletions are required
Q. What is the primary advantage of using a dynamic array over a static array?
A.
Faster access time
B.
Less memory usage
C.
Automatic resizing
D.
Easier to implement
Solution
Dynamic arrays can automatically resize themselves when they reach capacity, which is a significant advantage over static arrays that have a fixed size.
Q. Which data structure is more efficient for implementing a stack?
A.
Array
B.
Linked List
C.
Both are equally efficient
D.
None of the above
Solution
While both can be used to implement a stack, a linked list is often more efficient for dynamic size management, as it does not require resizing like an array.