Explore topic-wise MCQs in Data Structures and Algorithms.

This section includes 11 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.

What is the below pseudo code trying to do, where pt is a node pointer and root pointer?

A. insert a new node
B. delete a node
C. search a node
D. count the number of nodesView Answer
Answer» B. delete a node
2.

When to choose Red-Black tree, AVL tree and B-trees?

A. many inserts, many searches and when managing more items respectively
B. many searches, when managing more items respectively and many inserts respectively
C. sorting, sorting and retrieval respectively
D. retrieval, sorting and retrieval respectively
Answer» B. many searches, when managing more items respectively and many inserts respectively
3.

Cosider the below formations of red-black tree. All the above formations are incorrect for it to be a redblack tree. then what may be the correct order?

A. 50-black root, 18-red left subtree, 100-red right subtree
B. 50-red root, 18-red left subtree, 100-red right subtree
C. 50-black root, 18-black left subtree, 100-red right subtree
D. 50-black root, 18-red left subtree, 100-black right subtree
Answer» B. 50-red root, 18-red left subtree, 100-red right subtree
4.

Why do we impose restrictions like . root property is black . every leaf is black . children of red node are black . all leaves have same black

A. to get logarithm time complexity
B. to get linear time complexity
C. to get exponential time complexity
D. to get constant time complexity
Answer» B. to get linear time complexity
5.

WHEN_TO_CHOOSE_RED-BLACK_TREE,_AVL_TREE_AND_B-TREES??$

A. many inserts, many searches and when managing more items respectively
B. many searches, when managing more items respectively and many inserts respectively
C. sorting, sorting and retrieval respectively
D. retrieval, sorting and retrieval respectively
Answer» B. many searches, when managing more items respectively and many inserts respectively
6.

How can you save memory when storing color information in Red-Black tree?

A. using least significant bit of one of the pointers in the node for color information
B. using another array with colors of each node
C. storing color information in the node structure
D. using negative and positive numbering
Answer» B. using another array with colors of each node
7.

Why Red-black trees are preferred over hash tables though hash tables have constant time complexity?

A. no they are not preferred
B. because of resizing issues of hash table and better ordering in redblack trees
C. because they can be implemented using trees
D. because they are balanced
Answer» C. because they can be implemented using trees
8.

When it would be optimal to prefer Red-black trees over AVL trees?

A. when there are more insertions or deletions
B. when more search is needed
C. when tree must be balanced
D. when log(nodes) time complexity is needed
Answer» B. when more search is needed
9.

Which of the following is an application of Red-black trees and why?

A. used to store strings efficiently
B. used to store integers efficiently
C. can be used in process schedulers, maps, sets
D. for efficient sorting
Answer» D. for efficient sorting
10.

What are the operations that could be performed in O(logn) time complexity by red-black tree?

A. insertion, deletion, finding predecessor, successor
B. only insertion
C. only finding predecessor, successor
D. for sorting
Answer» B. only insertion
11.

What is the special property of red-black trees and what root should always be?

A. a color which is either red or black and root should always be black color only
B. height of the tree
C. pointer to next node
D. a color which is either green or black
Answer» B. height of the tree