Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Multiple Choice Questions
Q21: In an array-based list implementation, what is the worst-case scenario for the add() method?
- A: Adding at the end
- B: Adding at the beginning
- C: Adding in the middle
- D: Adding after removal
View Answer
B
Q22: What does the length() method return in a list implementation?
- A: Number of elements in the list
- B: Size of the array
- C: Index of the current element
- D: Memory used by the list
View Answer
A
Q23: What does the back() method do in an array-based list implementation?
- A: Moves current backward one step
- B: Moves current to the first element
- C: Moves current to the last element
- D: Moves current forward one step
View Answer
A
Q24: Which function is used to traverse and search for an element in a list?
- A: search()
- B: traverse()
- C: find()
- D: scan()
View Answer
C
Q25: What is the function of the update(x) method in a list?
- A: Adds element x to the end
- B: Removes current element
- C: Changes value at current position
- D: Finds element x
View Answer
C
Q26: In a linked list, what does the next field of the last node point to?
- A: Head of the list
- B: The first node
- C: NULL
- D: Current node
View Answer
C
Q27: How is a linked list stored in memory?
- A: Contiguously
- B: In non-contiguous memory blocks
- C: Sequentially
- D: Randomly
View Answer
B
Q28: What does the head pointer in a linked list indicate?
- A: The last node
- B: The first node
- C: The current node
- D: The previous node
View Answer
B
Q29: In an array-based list, what is the complexity of removing the first element?
- A: O(1)
- B: O(log n)
- C: O(n)
- D: O(n^2)
View Answer
C
Q30: What happens when you try to move the current pointer backward from the first element in an array-based list?
- A: It stays at the first element
- B: It wraps around to the last element
- C: It throws an error
- D: It removes the first element
View Answer
C