Q. In Python, which built-in data type can be used as a stack?
-
A.
List
-
B.
Tuple
-
C.
Set
-
D.
Dictionary
Solution
In Python, a list can be used as a stack by using append() to push and pop() to remove elements.
Correct Answer:
A
— List
Learn More →
Q. What is the primary disadvantage of using an array over a linked list?
-
A.
Memory overhead
-
B.
Fixed size
-
C.
Slower access
-
D.
Complex implementation
Solution
Arrays have a fixed size, which can be a disadvantage compared to linked lists that can grow dynamically.
Correct Answer:
B
— Fixed size
Learn More →
Q. Which of the following is a characteristic of a linked list?
-
A.
Fixed size
-
B.
Dynamic size
-
C.
Random access
-
D.
Contiguous memory allocation
Solution
A linked list can grow and shrink in size dynamically, unlike arrays which have a fixed size.
Correct Answer:
B
— Dynamic size
Learn More →
Q. Which of the following is true about a doubly linked list?
-
A.
Each node has one pointer
-
B.
Nodes can be traversed in both directions
-
C.
It uses less memory than a singly linked list
-
D.
It is always sorted
Solution
A doubly linked list allows traversal in both directions because each node has two pointers.
Correct Answer:
B
— Nodes can be traversed in both directions
Learn More →
Showing 1 to 4 of 4 (1 Pages)