Explore topic-wise MCQs in Testing Subject.

This section includes 657 Mcqs, each offering curated multiple-choice questions to sharpen your Testing Subject knowledge and support exam preparation. Choose a topic below to get started.

1.

If we implement heap as min-heap , deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start.

A. 2
B. 100
C. 17
D. 3
Answer» B. 100
2.

In .., it is possible to traverse a tree without using stacks either implicitly or explicitly.

A. Threaded binary trees
B. AVL Tree
C. B+ tree
D. Heap
Answer» D. Heap
3.

For construction of a binary heap with property that parent node has value less than child node.In reference to that which line is incorrect. Line indexed from 1.

A. Line -3
B. Line 5
C. Line 6
D. Line -7
Answer» C. Line 6
4.

Given that 2 elements are present in the tree, write a function to find the LCA(Least Common Ancestor) of the 2 elements.

A. A
B. B
C. C
D. D
Answer» D. D
5.

Given the code ,choose the correct option that is consistent with the code.Here A is the heap

A. It is the build function of max heap
B. It is the build function of min heap
C. It is general build function of any heap
D. None of the mentioned
Answer» B. It is the build function of min heap
6.

Heap is an example of .

A. Complete binary tree
B. Spanning tree
C. Sparse tree
D. Binary search tree
Answer» B. Spanning tree
7.

Herder node is used as sentinel in ..

A. Graphs
B. Stacks
C. Binary tree
D. Queues
Answer» D. Queues
8.

How many distinct binary search trees can be formed which contains the integers 1, 2, 3?

A. 6
B. 5
C. 4
D. 3
Answer» C. 4
9.

In a Heap tree

A. Values in a node is greater than every value in left sub tree and smaller than right sub tree
B. Values in a node is greater than every value in children of it
C. Both of above conditions applies
D. None of above conditions applies
Answer» C. Both of above conditions applies
10.

In a min heap

A. Minimum values are stored.
B. Child nodes have less value than parent nodes.
C. Parent nodes have less value than child nodes.
D. Maximum value is contained by the root node.
Answer» D. Maximum value is contained by the root node.
11.

In a min-heap:

A. Parent nodes have values greater than or equal to their Children
B. Parent nodes have values less than or equal to their Children
C. Both statements are true
D. Both statements are wrong
Answer» B. Parent nodes have values less than or equal to their Children
12.

In binary heap, whenever the root is removed then the rightmost element of last level is replaced by the root. Why?

A. It is the easiest possible way.
B. To make sure that it is still complete binary tree.
C. Because left and right subtree might be missing.
D. None of the above.
Answer» C. Because left and right subtree might be missing.
13.

In how many different ways can a tree be traversed?

A. Two ways
B. Three ways
C. One way
D. It cannot be traversed
Answer» C. One way
14.

In order traversal of binary search tree will produce

A. Unsorted list
B. Reverse of input
C. Sorted list
D. None of the above
Answer» D. None of the above
15.

In order to get the information stored in a Binary Search Tree in the descending order, one should traverse it in which of the following order?

A. Left, root, right
B. Root, left, right
C. Right, root, left
D. Right, left, root
Answer» D. Right, left, root
16.

In pre-order traversal, the root node is visited before traversing its________subtrees.

A. Left
B. Right
C. Both (a) and (b)
D. None of the above
Answer» D. None of the above
17.

The following formula is of :left_subtree (keys) node (key) right_subtree (keys)

A. Bianry Tree
B. Complete Binary Tree
C. Binary Search Tree
D. All of the above
Answer» D. All of the above
18.

The in-order traversal of a binary tree is HFIEJGZ, and the post-order traversal of the same tree is HIFJZGE. What will be the total number of nodes in the left sub tree of the given tree? (It is NOT a search tree)

A. 1
B. 2
C. 3
D. 4
Answer» D. 4
19.

The linked representation of a binary tree is implemented by using a linked list having an_________.

A. Info part
B. Two pointers- left and right
C. Both (a) and (b)
D. One pointer
Answer» D. One pointer
20.

The node at the top of a tree is known as the ________of the tree.

A. Heap
B. Leaf nodes
C. Child nodes
D. Root
Answer» E.
21.

The nodes belonging to the same parent node are known as_______.

A. Sibling nodes
B. Parent nodes
C. Child nodes
D. None of the above
Answer» B. Parent nodes
22.

The nodes belonging to the same parent node are known as_________.

A. Parent nodes
B. Sibling nodes
C. Tree nodes
D. None of the above
Answer» C. Tree nodes
23.

The number of nodes that have no successors in a complete binary tree of depth 4 is

A. 0
B. 8
C. 16
D. 4
Answer» C. 16
24.

The number of unused pointers in a complete binary tree of depth 5 is:

A. 4
B. 8
C. 16
D. 32
Answer» D. 32
25.

The order of a B-Tree with 2, 3, 4 or 5 children in every internal node is

A. 2
B. 3
C. 4
D. 5
Answer» D. 5
26.

The pre-order and post order traversal of a Binary Tree generates the same output. The tree can have maximum

A. Three nodes
B. Two nodes
C. One node
D. Any number of nodes
Answer» D. Any number of nodes
27.

The pre-order traversal of a binary-search tree is DBACFE. What is the post-order traversal?

A. ABFCDE
B. ADBFEC
C. ABFEDC
D. ACBEFD
Answer» E.
28.

The running time for creating a heap of size n is .

A. O(n)
B. O(log n)
C. O(n log n)
D. O(n^2)
Answer» D. O(n^2)
29.

The process of inserting a node in a binary search tree can be divided into how many steps?

A. Three
B. Two
C. Four
D. None of the above
Answer» C. Four
30.

The property of binary tree is

A. The first subset is called left subtree
B. The second subtree is called right subtree
C. The root cannot contain NULL
D. The right subtree can be empty
Answer» E.
31.

The smallest number of key that will force a B-tree of order 3 to have a height 3 is

A. 5
B. 7
C. 12
D. 16
Answer» C. 12
32.

Traversing a binary tree first root and then left and right subtrees called _______traversal.

A. Inorder
B. Preorder
C. Postorder
D. None of these
Answer» C. Postorder
33.

Traversing a binary tree refers to the process of visiting each and every node of the tree exactly how many times?

A. Once
B. Twice
C. Thrice
D. None
Answer» B. Twice
34.

Trees are often used in implementing _________ and hence it is considered as prime application of trees.

A. Chess
B. Players
C. Games
D. None of the above
Answer» D. None of the above
35.

Unlike a general tree, each node in a binary tree is restricted to have at the most __________child nodes only.

A. Four
B. Three
C. Two
D. One
Answer» D. One
36.

Visiting root node after visiting left and right sub-trees is called

A. In-order Traversal
B. Pre-order Traversal
C. Post-order Traveral
D. None of the above
Answer» D. None of the above
37.

Visiting root node after visiting left and right sub-trees is called .

A. In-order Traversal
B. Pre-order Traversal
C. Post-order Traversal
D. None of these
Answer» D. None of these
38.

What is inefficient with the below threaded binary tree picture?

A. It has dangling pointers
B. Nothing inefficient
C. Incorrect threaded tree
D. Space is being used more
Answer» B. Nothing inefficient
39.

What is missing in this logic of finding a path in the tree for a given sum (i.e checking whether there will be a path from roots to leaf nodes with given sum)?

A. Code for having recursive calls to either only left tree or right trees or to both subtrees depending on their existence
B. Code for having recursive calls to either only left tree or right trees
C. Code for having recursive calls to either only left tree
D. Code for having recursive calls to either only right trees
Answer» B. Code for having recursive calls to either only left tree or right trees
40.

What is one of the most common operations that is performed on trees?

A. Traversal of nodes
B. Threads
C. Pointers
D. None of the above
Answer» B. Threads
41.

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 nodes
Answer» B. Delete a node
42.

What is the maximum possible number of nodes in a binary tree at level 6?

A. 36
B. 6
C. 1
D. 64
Answer» E.
43.

Which of the below statements are true: i.Cartesian tree is not a height balanced tree ii.Cartesian tree of a sequence of unique numbers can be unique generated

A. Both statements are true
B. Only i. is true
C. Only ii. is true
D. Both are false
Answer» B. Only i. is true
44.

Which of the following need not to be a binary tree ?

A. Heap
B. B-Tree
C. AVL-Tree
D. Search tree
Answer» C. AVL-Tree
45.

Which of the following remarks about Tree- indexing are true?

A. It is an m-ary tree
B. Successful searches should terminate in leaf nodes
C. Unsuccessful searches may terminate in leaf nodes level of the tree structure
D. All of these
Answer» E.
46.

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
47.

Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities?for binary heap-insert: O(log n)-delete min: O(log n)for a tree-insert: O(log n)-delete: O(log n)Then why go with array representation when both are having same values ?

A. Arrays can store trees which are complete and heaps are by it s property are complete
B. Lists representation takes more memory hence memory efficiency is less and go with arrays
C. Array have better caching
D. All of the mentioned
Answer» E.
48.

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 trees
Answer» B. The logic is incorrect