Explore topic-wise MCQs in Data Structures and Algorithms.

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

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 – 7View Answer
Answer» D. Line – 7View Answer
2.

Given an array of element 5, 7, 9, 1, 3, 10, 8, 4. Which of the following are the correct sequences of elements after inserting all the elements in a min-heap?

A. 1,3,4,5,7,8,9,10
B. 1,4,3,9,8,5,7,10
C. 1,3,4,5,8,7,9,10
D. 1,3,7,4,8,5,9,10
Answer» B. 1,4,3,9,8,5,7,10
3.

State the complexity of algorithm given below.

A. o(n)
B. O(logn)
C. O(1)
D. O(n logn)View Answer
Answer» D. O(n logn)View Answer
4.

What is the location of a parent node for any arbitary node i?

A. (i/2) position
B. (i+1)/ position
C. floor(i/2) position
D. ceil(i/2) position
Answer» D. ceil(i/2) position
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. It is used to search element in any heapView Answer
Answer» B. It is the build function of min heap
6.

What is the best case complexity in building a heap?

A. O(nlogn)
B. O(n2)
C. O(n*longn *logn)
D. O(n)
Answer» E.
7.

A binary search tree is used to locate the number 43. Which one of the following probe sequence is not possible?

A. 61, 52, 14, 17, 40, 43
B. 10, 65, 31, 48, 37, 43
C. 81, 61, 52, 14, 41, 43
D. 17, 77, 27, 66, 18, 43
Answer» E.
8.

A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is smaller than the maximum element in T?

A. Θ(1)
B. Θ(n log n)
C. Θ(log n)
D. Θ(n)
Answer» B. Θ(n log n)
9.

Priority queue is implemented by:

A. Doubly link list
B. Graph
C. Heap
D. Stack
Answer» D. Stack
10.

Consider the following two statements.1. A binary tree T is full if each node is either a leaf or possesses exactly two child nodes.2. A binary tree T with n levels is complete if all levels except possibly the last are completely full, and the last level has all its nodes to the left side.Which statement is/are TRUE

A. Only 1
B. Only 2
C. 1 and 2
D. Neither 1 nor 2
Answer» D. Neither 1 nor 2
11.

Following numbers(items) are inserted in order into binary search tree.40,60,50,33,55,11Then the number of items in left and right subtrees of the root are _______

A. (3,3)
B. (2,3)
C. (3,2)
D. (2,4)
Answer» C. (3,2)
12.

In ______ balance factor of a node is the difference between left subtree and right subtree.

A. AVL tree
B. Red Black Tree
C. B+ Tree
D. 2-3 Tree
Answer» B. Red Black Tree
13.

Consider the binary search tree with n elements. The time required to search given element is: _______

A. θ (log n)
B. θ (n log n)
C. θ (n2)
D. θ (n2 log n)
Answer» B. θ (n log n)
14.

Consider the following statements:I. The smallest element in a max-heap is always at a leaf nodeII. The second largest element in a max-heap is always a child of the root nodeIII. A max-heap can be constructed from a binary search tree in Θ(n) timeIV. A binary search tree can be constructed from a max-heap in Θ(n) timeWhich of the above statements are TRUE?

A. I, II and III
B. I, II and IV
C. I, III and IV
D. II, III and IV
Answer» B. I, II and IV
15.

Consider the following binary search tree T given below. Which node contains the fourth smallest element in T ?

A. Q
B. V
C. W
D. X
Answer» D. X
16.

Consider an array representation of an n element binary heap where the elements are stored from index 1 to index n of the array. For the element stored at index i of the array (i < = n), the index of the parent is:

A. floor ((i + 1) / 2)
B. ceiling ((i + 1) / 2
C. floor (i / 2)
D. ceiling (i / 2)
Answer» D. ceiling (i / 2)
17.

Binary search tree contains the values 1, 2, 3, 4, 5, 6, 7, 8. The tree is traversed in pre-order and the values are printed out. Which of the following sequences is a valid output?

A. 53124786
B. 53126487
C. 53241678
D. 53124768
Answer» E.
18.

What is the location of parent node for any arbitary node i?

A. (i/2) position
B. (i+1)/ position
C. floor(i/2) position
D. ceil(i/2) position
Answer» D. ceil(i/2) position
19.

What is the best case complexity in builading a heap?

A. O(nlogn)
B. O(n<sup>2</sup>)
C. O(n*longn *logn)
D. O(n)
Answer» E.
20.

What is the space complexity of searching in a heap?

A. O(logn)
B. O(n)
C. O(1)
D. O(nlogn)
Answer» C. O(1)