Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Chapter: 5
Q101:
What does the remove method do in the CList class?
A. Adds an element
B. Moves to the next element
C. Retrieves the current element
D. Removes the current element
Correct Answer:
D
Chapter: 5
Q102:
How does a stack differ from a queue?
A. Stack is FIFO, queue is LIFO
B. Stack is LIFO, queue is FIFO
C. Stack is circular, queue is linear
D. Stack allows random access
Correct Answer:
B
Chapter: 6
Q103:
What is the primary characteristic of a stack data structure?
A. FIFO (First In, First Out)
B. LIFO (Last In, First Out)
C. FILO (First In, Last Out)
D. LILO (Last In, Last Out)
Correct Answer:
B
Chapter: 6
Q104:
Why do we use the isFull() method in stack implementation using arrays?
A. To check if the array is empty
B. To check the size of the stack
C. To prevent adding elements beyond capacity
D. To allocate more memory dynamically
Correct Answer:
C
Chapter: 6
Q105:
What is the main advantage of using a linked list over an array for stack implementation?
A. Constant time complexity
B. Dynamic memory allocation
C. No need for isEmpty() method
D. Easier to implement operations
Correct Answer:
B
Chapter: 6
Q106:
In a stack implemented using a linked list, where is the new element inserted?
A. At the start of the list
B. At the end of the list
C. In the middle of the list
D. It depends on implementation
Correct Answer:
A
Chapter: 6
Q107:
How is the pop() operation implemented in a linked list-based stack?
A. Removes the last node
B. Removes the first node
C. Removes a random node
D. Replaces the first node value
Correct Answer:
B
Chapter: 6
Q108:
Which method retrieves the top element of the stack without removing it?
A. pop()
B. push()
C. isEmpty()
D. top()
Correct Answer:
D
Chapter: 6
Q109:
What does the isEmpty() method check in a stack implementation?
A. If the stack is full
B. If the stack has any elements
C. If the head pointer is NULL
D. If memory allocation has failed
Correct Answer:
C
Chapter: 6
Q110:
Which of the following is not required when implementing a stack using a linked list?
A. isFull()
B. isEmpty()
C. push()
D. pop()
Correct Answer:
A
Chapter: 6
Q111:
Why might an array-based stack implementation be preferred over a linked list?
A. Uses less memory overall
B. Easier to resize dynamically
C. Faster memory allocation
D. Lower overhead for small datasets
Correct Answer:
D
Chapter: 6
Q112:
What is the primary disadvantage of using a linked list for stack implementation?
A. Higher time complexity
B. Limited memory space
C. Extra memory required for pointers
D. Harder to implement
Correct Answer:
C
Chapter: 6
Q113:
What does the expression A + B * C evaluate to in infix notation?
A. A + B * C
B. A + (B * C)
C. (A + B) * C
D. A * B + C
Correct Answer:
B
Chapter: 6
Q114:
How would you convert the infix expression A + B to postfix notation?
A. A B +
B. + A B
C. A + B
D. B A +
Correct Answer:
A
Chapter: 6
Q115:
Which operator has the highest precedence in arithmetic expressions?
A. Addition
B. Multiplication
C. Exponentiation
D. Subtraction
Correct Answer:
C
Chapter: 6
Q116:
What is the correct order of precedence for the operators in the expression A + B * C?
A. Addition > Multiplication
B. Multiplication > Addition
C. Equal precedence
D. Depends on the operands
Correct Answer:
B
Chapter: 6
Q117:
In postfix notation, how would the expression (A + B) * C be written?
A. A B + C *
B. A + B C *
C. A B C + *
D. (A + B) * C
Correct Answer:
A
Chapter: 6
Q118:
In stack implementation using an array, why is the isFull() method important?
A. To avoid crashing the program
B. To dynamically allocate more space
C. To ensure the array is sorted
D. To initialize the array
Correct Answer:
A
Chapter: 6
Q119:
What is the main reason for not using isFull() in a stack implemented with a linked list?
A. Memory is managed dynamically
B. Linked lists are infinite
C. Nodes do not require memory
D. The head pointer handles fullness
Correct Answer:
A
Chapter: 6
Q120:
What is the key difference between a stack implemented using an array and a linked list?
A. Array is slower
B. Linked list uses more memory
C. Linked list does not have a fixed size
D. Array supports dynamic resizing
Correct Answer:
C