Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Chapter: 28
Q461:
In a complete binary tree, where is the right child of a node located if it is at position i in an array?
A. 2 * i + 1
B. 2 * i
C. i + 1
D. 2 * (i + 2)
Correct Answer:
A
Chapter: 28
Q462:
What is the purpose of level-order traversal in a complete binary tree?
A. To store the tree in an array efficiently
B. To find the inorder traversal
C. To find the height of the tree
D. To traverse the tree in depth-first order
Correct Answer:
A
Chapter: 28
Q463:
What does the floor(i / 2) formula determine in the context of a complete binary tree stored in an array?
A. The parent node position
B. The left child node position
C. The right child node position
D. The sibling node position
Correct Answer:
A
Chapter: 28
Q464:
Which of the following statements is true about a complete binary tree?
A. It can be stored in an array with indices
B. It is always a binary search tree
C. It is always perfectly complete
D. It always requires pointers for traversal
Correct Answer:
A
Chapter: 28
Q465:
What is a unique feature of a complete binary tree when compared to a perfect binary tree?
A. The last level is not necessarily fully filled
B. All nodes have exactly two children
C. All levels are completely filled
D. The tree is not balanced
Correct Answer:
A
Chapter: 28
Q466:
What is the purpose of using the fastInorder routine instead of a recursive inorder traversal?
A. To avoid the use of stack and recursion
B. To find the level-order traversal
C. To traverse the tree in postorder
D. To use additional memory
Correct Answer:
A
Chapter: 29
Q467:
What is a Complete Binary Tree?
A. A tree where all levels are fully filled except possibly the last one
B. A tree where every node has two children
C. A tree with a single node
D. A tree with nodes arranged in a linked list
Correct Answer:
A
Chapter: 29
Q468:
Why are arrays not ideal for storing incomplete binary trees?
A. Arrays require contiguous memory allocation
B. Arrays cannot handle dynamic size changes
C. Arrays have fixed sizes
D. Arrays have memory wastage due to empty positions
Correct Answer:
D
Chapter: 29
Q469:
In a min-heap, what property must be satisfied for every node?
A. The node value must be greater than its children
B. The node value must be smaller than its children
C. The node value must be equal to its children
D. The node value must be random with respect to children
Correct Answer:
B
Chapter: 29
Q470:
What happens when you remove the root node from a min-heap?
A. The tree is destroyed
B. The remaining values are rearranged to form a new heap
C. The root node is replaced with the maximum value
D. The heap property is violated permanently
Correct Answer:
B
Chapter: 29
Q471:
How do you maintain heap property when inserting a new value into a heap?
A. By moving the new value to the root
B. By replacing the new value with the minimum value
C. By adjusting the tree to restore heap property
D. By removing the smallest value from the heap
Correct Answer:
C
Chapter: 29
Q472:
What is a max heap?
A. A heap where the root node has the smallest value
B. A heap where the root node has the largest value
C. A heap with unordered nodes
D. A heap where all nodes are equal
Correct Answer:
B
Chapter: 29
Q473:
How is a node inserted into a heap?
A. At the root node
B. At the end of the heap and then adjusted
C. At any random position
D. Directly into the middle of the heap
Correct Answer:
B
Chapter: 29
Q474:
What is the formula used to find the parent node's index in an array representation of a heap?
A. i / 2
B. 2i + 1
C. (i - 1) / 2
D. 2i
Correct Answer:
A
Chapter: 29
Q475:
What does a complete binary tree ensure when using an array for storage?
A. Efficient use of memory
B. Fast sorting of elements
C. Quick access to parent nodes
D. Contiguous allocation of nodes
Correct Answer:
A
Chapter: 29
Q476:
How are pointers used in dynamic memory allocation compared to arrays in the context of data structures?
A. Pointers provide faster access
B. Pointers reduce memory wastage
C. Arrays are more efficient
D. Pointers manage memory efficiently and dynamically
Correct Answer:
D
Chapter: 29
Q477:
What operation is used to adjust the position of nodes after inserting a new value in a heap?
A. Deletion operation
B. Heapify operation
C. Sorting operation
D. Traversal operation
Correct Answer:
B
Chapter: 29
Q478:
In a min-heap, if a new node has a value less than its parent, what is the result?
A. The new node remains in place
B. The new node becomes the root
C. The new node is removed
D. The new node is swapped with its parent and potentially other nodes
Correct Answer:
B
Chapter: 29
Q479:
Which data structure is often used to implement a priority queue?
A. Stack
B. Queue
C. Heap
D. Linked List
Correct Answer:
C
Chapter: 29
Q480:
How are elements rearranged in a heap after the insertion of a new value?
A. By merging elements
B. By swapping elements to restore heap property
C. By sorting the entire heap
D. By reversing the order of elements
Correct Answer:
B