Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Chapter: 4
Q81:
What happens to the size of the list after deleting a node?
A. Increases by 1
B. Decreases by 1
C. Remains the same
D. Doubles
Correct Answer:
B
Chapter: 4
Q82:
What is the initial value of currentNode in the start() method?
A. NULL
B. headNode
C. lastCurrentNode
D. size
Correct Answer:
B
Chapter: 5
Q83:
What is the purpose of the add method in the CList class?
A. Adds elements to the list
B. Removes elements from the list
C. Moves to the next element
D. Returns the length of the list
Correct Answer:
A
Chapter: 5
Q84:
Which method in the CList class is used to remove an element?
A. add
B. start
C. remove
D. next
Correct Answer:
C
Chapter: 5
Q85:
What does the get method do in the CList class?
A. Removes an element
B. Adds an element
C. Retrieves the current element
D. Moves to the next element
Correct Answer:
C
Chapter: 5
Q86:
In a circular linked list, what happens to the next method?
A. It returns NULL at the last node
B. It loops back to the first node
C. It throws an exception
D. It stops at the last node
Correct Answer:
B
Chapter: 5
Q87:
Why is the circular linked list preferred for solving the Josephus problem?
A. It simplifies the problem
B. It is faster
C. It reduces code complexity
D. It is easier to implement
Correct Answer:
A
Chapter: 5
Q88:
What is a key advantage of using the CList class in the Josephus problem?
A. Encapsulation of data and methods
B. Simplifies moving elements
C. Direct access to elements
D. Better memory management
Correct Answer:
A
Chapter: 5
Q89:
What is the Abstract Data Type (ADT)?
A. A physical data structure
B. A specific programming method
C. A collection of values and operations
D. A type of programming language
Correct Answer:
C
Chapter: 5
Q90:
Why is the interface important in ADT?
A. It defines internal implementation
B. It can be changed without affecting the user
C. It is hard to modify
D. It is specific to one implementation
Correct Answer:
B
Chapter: 5
Q91:
Which method should be called before pop to avoid errors in stack?
A. isEmpty
B. isFull
C. top
D. push
Correct Answer:
A
Chapter: 5
Q92:
How is a stack typically implemented using an array?
A. Elements are inserted at the start
B. Elements are inserted at the end
C. Elements are inserted in the middle
D. Elements are inserted randomly
Correct Answer:
B
Chapter: 5
Q93:
What happens in a stack when push(5) is called?
A. The top element is returned
B. The element is added to the top
C. The stack is reversed
D. The bottom element is removed
Correct Answer:
B
Chapter: 5
Q94:
Which data structure is described as LIFO?
A. Queue
B. Stack
C. Array
D. Linked List
Correct Answer:
B
Chapter: 5
Q95:
What is the result of calling pop() on an empty stack?
A. It returns the last element
B. It throws an exception
C. It returns NULL
D. It does nothing
Correct Answer:
B
Chapter: 5
Q96:
What does the top() method do in a stack?
A. Removes the top element
B. Returns the top element without removing it
C. Moves to the bottom element
D. Clears the stack
Correct Answer:
B
Chapter: 5
Q97:
What is the best case scenario for push() and pop() in an array-based stack?
A. Insertion/removal at the start
B. Insertion/removal in the middle
C. Insertion/removal at the end
D. Insertion/removal randomly
Correct Answer:
C
Chapter: 5
Q98:
What problem arises when implementing a stack using an array?
A. Overflow if the array is full
B. Difficulty in accessing elements
C. Inefficient memory usage
D. Hard to implement
Correct Answer:
A
Chapter: 5
Q99:
Why is encapsulation important in the context of ADT?
A. It hides the implementation details
B. It speeds up the program
C. It provides direct access to data
D. It makes the program complex
Correct Answer:
A
Chapter: 5
Q100:
What happens when you try to divide a number by zero in C++?
A. The program continues
B. It returns 0
C. It throws a 'division by zero' exception
D. It ignores the operation
Correct Answer:
C