☑ MCQ PRACTICE

Data Structures Unit 3

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

📚 Data Structures
📖 Unit 3
🎯 MCQs

Data Structures - Unit-3

1
How many children does a binary tree have?
A2
Bany number of children
C0 or 1 or 2
D0 or 1
Correct Answer 0 or 1 or 2
2
To represent hierarchical relationship between elements, Which data structure is suitable?
AQueue
BStack
CTree
DGraph
Correct Answer Tree
3
What is/are the disadvantages of implementing tree using normal arrays?
Adifficulty in knowing children nodes of a node
Bdifficult in finding the parent of a node
Chave to know the maximum number of nodes possible before creation of trees
Ddifficult to implement
Correct Answer have to know the maximum number of nodes possible before creation of trees
4
Advantages of linked list representation of binary trees over arrays?
Adynamic size
Bease of insertion/deletion
Cease in randomly accessing a node
Dboth dynamic size and ease in insertion/deletion
Correct Answer both dynamic size and ease in insertion/deletion
5
Disadvantages of linked list representation of binary trees over arrays?
ARandomly accessing is not possible
BExtra memory for a pointer is needed with every element in the list
CDifficulty in deletion
DRandom access is not possible and extra memory with every element
Correct Answer Random access is not possible and extra memory with every element
6
If binary trees are represented in arrays, what formula can be used to locate a left child, if the parent node has an index i?
A2i+1
B2i+2
Ci+1
Di+2
Correct Answer 2i+1
7
Using what formula can a parent node be located in an array?
A(i+1)/2
B(i-1)/2
Ci/2
D2i/2
Correct Answer (i-1)/2
8
Which of the following properties are obeyed by all three tree – traversals?
ALeft subtrees are visited before right subtrees
BRight subtrees are visited before left subtrees
CRoot node is visited before left subtree
DRoot node is visited before right subtree
Correct Answer Left subtrees are visited before right subtrees
9
A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a valid post-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70, 40 and 75?
A7, 8, 26, 13, 75, 40, 70, 35
B26, 13, 7, 8, 70, 75, 40, 35
C7, 8, 13, 26, 35, 40, 70, 75
D8, 7, 26, 13, 40, 75, 70, 35
Correct Answer 8, 7, 26, 13, 40, 75, 70, 35
10
In a binary search tree, which of the following traversals would print the numbers in the ascending order?
ALevel-order traversal
BPre-order traversal
CPost-order traversal
DIn-order traversal
Correct Answer In-order traversal
11
The number of edges from the root to the node is called __________ of the tree.
AHeight
BDepth
CLength
DWidth
Correct Answer Depth
12
The number of edges from the node to the deepest leaf is called _________ of the tree.
AHeight
BDepth
CLength
DWidth
Correct Answer Height
13
What is a full binary tree?
AEach node has exactly zero or two children
BEach node has exactly two children
CAll the leaves are at the same level
DEach node has exactly one or two children
Correct Answer Each node has exactly zero or two children
14
What is a complete binary tree?
AEach node has exactly zero or two children
BA binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left
CA binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
DA tree In which all nodes have degree 2
Correct Answer A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
15
Which of the following is false about a binary search tree?
AThe left child is always lesser than its parent
BThe right child is always greater than its parent
CThe left and right sub-trees should also be binary search trees
DIn order sequence gives decreasing order of elements
Correct Answer In order sequence gives decreasing order of elements
16
What is the main characteristic of a B Tree?
AEach node has a variable number of children within a specified range.
BNodes are arranged in a binary structure.
CTree height is logarithmic in the number of elements.
DAll nodes store the same number of keys.
Correct Answer Each node has a variable number of children within a specified range.
17
In a B Tree, what property does the order 'm' define?
AMaximum number of children a node can have.
BMaximum height of the tree.
CMaximum number of keys a node can have.
DMaximum number of nodes in the tree.
Correct Answer Maximum number of children a node can have.
18
Which of the following operations can be performed efficiently using a B Tree?
AMultiplication of sparse matrices
BInsertion, deletion, and search of keys in a database
CFinding the shortest path in a graph
DBalancing a binary search tree
Correct Answer Insertion, deletion, and search of keys in a database
19
What is a significant advantage of using B Trees in database systems?
AThey require less memory than binary search trees.
BThey ensure minimal disk I/O operations.
CThey do not require balancing.
DThey can store any type of data without conversion.
Correct Answer They ensure minimal disk I/O operations.
20
How do B+ Trees differ from B Trees?
AB+ Trees are binary trees, while B Trees are multi-way trees.
BIn B+ Trees, all keys are stored in leaf nodes and internal nodes act as routing guides.
CB+ Trees do not allow duplicates, while B Trees do.
DB+ Trees have a fixed height, while B Trees have variable height.
Correct Answer In B+ Trees, all keys are stored in leaf nodes and internal nodes act as routing guides.
21
What is the advantage of B+ Trees over B Trees in terms of range queries?
AB+ Trees require fewer comparisons for range queries.
BB+ Trees provide faster access to individual keys.
CLeaf nodes of B+ Trees are linked, providing efficient full-range scans.
DB+ Trees have a simpler structure, making range queries more straightforward.
Correct Answer Leaf nodes of B+ Trees are linked, providing efficient full-range scans.
22
In a B+ Tree, where are the actual records pointed to by the keys stored?
AIn every node
BOnly in root nodes
COnly in internal nodes
DOnly in leaf nodes
Correct Answer Only in leaf nodes
23
Why are B+ Trees preferred in database indexing over B Trees?
AB+ Trees provide faster insertion and deletion operations.
BThe linked leaf nodes in B+ Trees make sequential access faster.
CB+ Trees require less disk space.
DB+ Trees are easier to implement.
Correct Answer The linked leaf nodes in B+ Trees make sequential access faster.
24
What is the key property of an AVL Tree?
AEvery node has at most two children.
BThe tree is a complete binary tree.
CThe difference in height between the left and right subtrees of any node is at most 1.
DAll leaf nodes are at the same level.
Correct Answer The difference in height between the left and right subtrees of any node is at most 1.
25
What is the time complexity of insertion in an AVL Tree?
AO(1)
BO(log n)
CO(n)
DO(n log n)
Correct Answer O(log n)
26
Which of the following operations can cause an AVL Tree to become unbalanced?
ASearching for a node
BInserting a node
CTraversing the tree
DComputing the height of the tree
Correct Answer Inserting a node
27
What mechanism is used to maintain the balance of an AVL Tree after insertion or deletion?
ARed-Black balancing
BSplay operation
CTree rotations
DB-tree splitting
Correct Answer Tree rotations
28
In the context of AVL Trees, what is a rotation?
ASwapping the values of two nodes
BMoving a subtree to a different location in the tree
CChanging the structure of the tree without altering the in-order sequence of elements
DChanging the root of the tree
Correct Answer Changing the structure of the tree without altering the in-order sequence of elements
29
What is the maximum number of rotations needed to balance an AVL Tree after a single insertion?
A1
B2
C3
D4
Correct Answer 2
30
How does the height of an AVL Tree compare to the height of a perfectly balanced binary tree?
AIt is always the same.
BIt can be up to twice as large.
CIt can be larger, but no more than log n.
DIt can be smaller, but no less than log n.
Correct Answer It can be larger, but no more than log n.
31
Which of the following is true about the deletion operation in an AVL Tree?
AIt cannot cause the tree to become unbalanced.
BIt may require rebalancing through rotations.
CIt is always performed without rotations.
DIt is less complex than deletion in a binary search tree.
Correct Answer It may require rebalancing through rotations.
32
What is a distinctive feature of a Red-Black Tree?
AEach node is colored either red or black.
BEach node can have up to three children.
CThe tree is always perfectly balanced.
DAll leaf nodes are at the same depth.
Correct Answer Each node is colored either red or black.
33
Which of these properties must a Red-Black Tree satisfy?
AEvery red node must have two black child nodes.
BEvery path from a node to its descendant NIL nodes has the same number of black nodes.
CAll leaf nodes are black.
DAll of the above.
Correct Answer All of the above.
34
What is the time complexity of insertion and deletion operations in a Red-Black Tree?
AO(1)
BO(log n)
CO(n)
DO(n log n)
Correct Answer O(log n)
35
What action is performed to maintain the Red-Black properties after an insertion or deletion?
ASplitting the tree
BRecoloring nodes and performing rotations
CSwapping sibling nodes
DConverting the tree to a binary search tree and then back to a red-black tree
Correct Answer Recoloring nodes and performing rotations
36
In a Red-Black Tree, what does the property "the tree has the same number of black nodes on any path from a node to a descendant leaf" ensure?
AThe tree is perfectly balanced.
BThe tree is height-balanced, with the longest path no more than twice the length of the shortest path.
CAll paths have the same length.
DThe tree is a full binary tree.
Correct Answer The tree is height-balanced, with the longest path no more than twice the length of the shortest path.
37
Which of the following operations may cause a violation of Red-Black Tree properties?
ASearching for a node
BInserting a node
CTraversing the tree
DComputing the height of the tree
Correct Answer Inserting a node
38
What is the maximum height of a Red-Black Tree with 'n' nodes?
A2 log₂(n+1)
Blog₂ n
Cn
D2n
Correct Answer 2 log₂(n+1)
39
Why are Red-Black Trees important in computer science?
AThey provide a worst-case guarantee for insertion, deletion, and search operations.
BThey are easier to implement than binary search trees.
CThey require less memory than AVL trees.
DThey do not require rebalancing after every insertion or deletion.
Correct Answer They provide a worst-case guarantee for insertion, deletion, and search operations.
40
What is a Splay Tree?
AA tree where recently accessed elements are quick to access again.
BA perfectly balanced binary search tree.
CA binary tree with unique height properties.
DA tree where each node has exactly two children.
Correct Answer A tree where recently accessed elements are quick to access again.
41
What is the key operation used in Splay Trees to maintain tree properties?
ASplitting
BColoring
CSplaying
DRotating
Correct Answer Splaying
42
What does the splaying operation in a Splay Tree do?
AMoves a node to the root through a series of rotations.
BSwaps two child nodes.
CEnsures all leaf nodes are at the same depth.
DBalances the tree perfectly after every operation.
Correct Answer Moves a node to the root through a series of rotations.
43
What is the time complexity of search, insert, and delete operations in a Splay Tree in the amortized case?
AO(1)
BO(log n)
CO(n)
DO(n log n)
Correct Answer O(log n)
44
Which of the following scenarios best demonstrates the advantage of a Splay Tree?
AWhen the tree is accessed randomly and there are no frequently accessed nodes.
BWhen certain nodes are accessed frequently and need to be accessed quickly.
CWhen the tree is used for one-time write and read operations.
DWhen the tree requires frequent rebalancing to maintain strict height balance.
Correct Answer When certain nodes are accessed frequently and need to be accessed quickly.
45
What property does a Splay Tree use to ensure that recently accessed elements are quick to access again?
AThe tree rebalances itself after every operation.
BNodes are colored red or black to indicate their access frequency.
CFrequently accessed nodes are moved closer to the root.
DLeaf nodes are linked together for faster sequential access.
Correct Answer Frequently accessed nodes are moved closer to the root.
46
In a Splay Tree, what happens after an element is accessed (searched, inserted, or delete?
AThe tree is left unchanged.
BThe accessed element is moved to the root of the tree.
CThe tree is completely rebuilt.
DThe accessed element is moved to a leaf position.
Correct Answer The accessed element is moved to the root of the tree.
47
Why might Splay Trees not be suitable in an environment with parallel or concurrent operations?
ABecause the structure of the tree changes frequently, making it hard to predict.
BBecause they are more memory-intensive than other trees.
CBecause splay operations are not thread-safe.
DBecause they do not support concurrent modifications well due to the restructuring after operations.
Correct Answer Because they do not support concurrent modifications well due to the restructuring after operations.
← Back to All MCQs