Explore topic-wise MCQs in Data Structures and Algorithms.

This section includes 12 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structures and Algorithms knowledge and support exam preparation. Choose a topic below to get started.

1.

Elements in a tree can be indexed by its position under the ordering of the keys and the ordinal position of an element can be determined, both with good efficiency.

A. true
B. false
Answer» B. false
2.

What does the below definations convey? i. A binary tree is balanced if for every node it is gonna hold that the number of inner nodes in the left subtree and the number of inner nodes in the right subtree differ by at most 1. ii. A binary tree is balanced if for any two leaves the difference of the depth is at most 1.

A. weight balanced and height balanced tree definations
B. height balanced and weight balanced tree definations
C. definations of weight balanced tree
D. definations of height balanced tree
Answer» B. height balanced and weight balanced tree definations
3.

Why the below pseudo code where x is a value, wt is weight factor and t is root node can’t insert?

A. when x>t. element Rotate-with-left-child should take place and vice versa
B. the logic is incorrect
C. the condition for rotating children is wrong
D. insertion cannot be performed in weight balanced treesView Answer
Answer» B. the logic is incorrect
4.

The size value of various nodes in a weight balanced tree are leaf – zero internal node – size of it’s two children is this true?

A. true
B. false
Answer» B. false
5.

ELEMENT_ROTATE-WITH-LEFT-CHILD_SHOULD_TAKE_PLACE_AND_VICE_VERSA?$

A. the logic is incorrect
B. the condition for rotating children is wrong
C. insertion cannot be performed in weight balanced trees
Answer» B. the condition for rotating children is wrong
6.

What_does_the_below_definations_convey?$

A.
B.
Answer» B.
7.

Consider a weight balanced tree such that, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the farthest leaf) of such a tree on k nodes can be described as

A. log2 n
B. log4/3 n
C. log3 n
D. log3/2 n
Answer» E.
8.

What are the operations that can be performed on weight balanced tree?

A. all basic operations and set intersection, set union and subset test
B. all basic operations
C. set intersection, set union and subset test
D. only insertion and deletion
Answer» B. all basic operations
9.

What is the condition for a tree to be weight balanced. where a is factor and n is a node?

A. weight[n.left] >= a*weight[n] and weight[n.right] >= a*weight[n].
B. weight[n.left] >= a*weight[n.right] and weight[n.right] >= a*weight[n].
C. weight[n.left] >= a*weight[n.left] and weight[n.right] >= a*weight[n].
D. weight[n] is a non zero
Answer» B. weight[n.left] >= a*weight[n.right] and weight[n.right] >= a*weight[n].
10.

A node of the weight balanced tree has

A. key, left and right pointers, size
B. key, value
C. key, size
D. key
Answer» B. key, value
11.

What are the applications of weight balanced tree?

A. dynamic sets, dictionaries, sequences, maps
B. heaps
C. sorting
D. storing strings
Answer» B. heaps
12.

What is a weight balanced tree?

A. A binary tree that stores the sizes of subtrees in nodes
B. A binary tree with an additional attribute of weight
C. A height balanced binary tree
D. A normal binary tree
Answer» B. A binary tree with an additional attribute of weight