188
96.4k

550+ Data Structures (DS) Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Bachelor of Science in Computer Science FY (BSc CS) , Bachelor of Science in Information Technology FY (BSc IT) , Bachelor of Computer Applications (BCA) .

Chapters

Chapter: Non Linear Data Structures - Trees
101.

In a binary search tree, which of the following traversals would print the numbers in the ascending order?

A. Level-order traversal
B. Pre-order traversal
C. Post-order traversal
D. In-order traversal
Answer» D. In-order traversal
102.

The number of edges from the root to the node is called of the tree.

A. Height
B. Depth
C. Length
D. Width
Answer» B. Depth
103.

The number of edges from the node to the deepest leaf is called of the tree.

A. Height
B. Depth
C. Length
D. Width
Answer» A. Height
104.

What is a full binary tree?

A. Each node has exactly zero or two children
B. Each node has exactly two children
C. All the leaves are at the same level
D. Each node has exactly one or two children
Answer» A. Each node has exactly zero or two children
105.

What is a complete binary tree?

A. Each node has exactly zero or two children
B. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left
C. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
D. A tree In which all nodes have degree 2
Answer» C. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
106.

What is the average case time complexity for finding the height of the binary tree?

A. h = O(loglogn)
B. h = O(nlogn)
C. h = O(n)
D. h = O(log n)
Answer» D. h = O(log n)
107.

Which of the following is not an advantage of trees?

A. Hierarchical structure
B. Faster search
C. Router algorithms
D. Undo/Redo operations in a notepad
Answer» D. Undo/Redo operations in a notepad
108.

In a full binary tree if number of internal nodes is I, then number of leaves L are?

A. L = 2*I
B. L = I + 1
C. L = I – 1
D. L = 2*I – 1
Answer» B. L = I + 1
109.

In a full binary tree if number of internal nodes is I, then number of nodes N are?

A. N = 2*I
B. N = I + 1
C. N = I – 1
D. N = 2*I + 1
Answer» D. N = 2*I + 1
110.

In a full binary tree if there are L leaves, then total number of nodes N are?

A. N = 2*L
B. N = L + 1
C. N = L – 1
D. N = 2*L – 1
Answer» D. N = 2*L – 1
111.

Which of the following is incorrect with respect to binary trees?

A. Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level k
B. Let T be a binary tree with λ levels. Then T has no more than 2λ – 1 nodes
C. Let T be a binary tree with N nodes. Then the number of levels is at least ceil(log (N + 1))
D. Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))
Answer» D. Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))
112.

Which of the following is false about a binary search tree?

A. The left child is always lesser than its parent
B. The right child is always greater than its parent
C. The left and right sub-trees should also be binary search trees
D. In order sequence gives decreasing order of elements
Answer» D. In order sequence gives decreasing order of elements
113.

What is the speciality about the inorder traversal of a binary search tree?

A. It traverses in a non increasing order
B. It traverses in an increasing order
C. It traverses in a random fashion
D. It traverses based on priority of the node
Answer» B. It traverses in an increasing order
114.

What are the worst case and average case complexities of a binary search tree?

A. O(n), O(n)
B. O(logn), O(logn)
C. O(logn), O(n)
D. O(n), O(logn)
Answer» D. O(n), O(logn)
115.

What are the conditions for an optimal binary search tree and what is its advantage?

A. The tree should not be modified and you should know how often the keys are accessed, it improves the lookup cost
B. You should know the frequency of access of the keys, improves the lookup time
C. The tree can be modified and you should know the number of elements in the tree before hand, it improves the deletion time
D. The tree should be just modified and improves the lookup time
Answer» A. The tree should not be modified and you should know how often the keys are accessed, it improves the lookup cost
116.

Which of the following is not the self balancing binary search tree?

A. AVL Tree
B. 2-3-4 Tree
C. Red – Black Tree
D. Splay Tree
Answer» B. 2-3-4 Tree
117.

The binary tree sort implemented using a self – balancing binary search tree takes time is worst case.

A. O(n log n)
B. O(n)
C. O(n2)
D. O(log n)
Answer» A. O(n log n)
118.

An AVL tree is a self – balancing binary search tree, in which the heights of the two child sub trees of any node differ by

A. At least one
B. At most one
C. Two
D. At most two
Answer» B. At most one
119.

Associative arrays can be implemented using

A. B-tree
B. A doubly linked list
C. A single linked list
D. A self balancing binary search tree
Answer» D. A self balancing binary search tree
120.

Which of the following is a self – balancing binary search tree?

A. 2-3 tree
B. Threaded binary tree
C. AA tree
D. Treap
Answer» C. AA tree
121.

A self – balancing binary search tree can be used to implement

A. Priority queue
B. Hash table
C. Heap sort
D. Priority queue and Heap sort
Answer» A. Priority queue
122.

In which of the following self – balancing binary search tree the recently accessed element can be accessed quickly?

A. AVL tree
B. AA tree
C. Splay tree
D. Red – Black tree
Answer» C. Splay tree
123.

The minimum height of self balancing binary search tree with n nodes is

A. log2(n)
B. n
C. 2n + 1
D. 2n – 1
Answer» A. log2(n)
124.

What is an AVL tree?

A. a tree which is balanced and is a height balanced tree
B. a tree which is unbalanced and is a height balanced tree
C. a tree with three children
D. a tree with atmost 3 children
Answer» A. a tree which is balanced and is a height balanced tree
125.

Why we need to a binary tree which is height balanced?

A. to avoid formation of skew trees
B. to save memory
C. to attain faster memory access
D. to simplify storing
Answer» A. to avoid formation of skew trees
126.

What is the maximum height of an AVL tree with p nodes?

A. p
B. log(p)
C. log(p)/2
D. P⁄2
Answer» B. log(p)
127.

Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given without performing any rotations?

A. just build the tree with the given input
B. find the median of the set of elements given, make it as root and construct the tree
C. use trial and error
D. use dynamic programming to build the tree
Answer» B. find the median of the set of elements given, make it as root and construct the tree
128.

What maximum difference in heights between the leafs of a AVL tree is possible?

A. log(n) where n is the number of nodes
B. n where n is the number of nodes
C. 0 or 1
D. atmost 1
Answer» A. log(n) where n is the number of nodes
129.

What is missing?

A. Height(w-left), x-height
B. Height(w-right), x-height
C. Height(w-left), x
D. Height(w-left)
Answer» A. Height(w-left), x-height
130.

Why to prefer red-black trees over AVL trees?

A. Because red-black is more rigidly balanced
B. AVL tree store balance factor in every node which costs space
C. AVL tree fails at scale
D. Red black is more efficient
Answer» B. AVL tree store balance factor in every node which costs space
131.

Which of the following is the most widely used external memory data structure?

A. AVL tree
B. B-tree
C. Red-black tree
D. Both AVL tree and Red-black tree
Answer» B. B-tree
132.

B-tree of order n is a order-n multiway tree in which each non-root node contains

A. at most (n – 1)/2 keys
B. exact (n – 1)/2 keys
C. at least 2n keys
D. at least (n – 1)/2 keys
Answer» D. at least (n – 1)/2 keys
133.

A B-tree of order 4 and of height 3 will have a maximum of keys.

A. 255
B. 63
C. 127
D. 188
Answer» A. 255
134.

Five node splitting operations occurred when an entry is inserted into a B-tree. Then how many nodes are written?

A. 14
B. 7
C. 11
D. 5
Answer» C. 11
135.

trees are B-trees of order 4. They are an isometric of trees.

A. AVL
B. AA
C. 2-3
D. Red-Black
Answer» D. Red-Black
136.

What is the best case height of a B-tree of order n and which has k keys?

A. logn (k+1) – 1
B. nk
C. logk (n+1) – 1
D. klogn
Answer» A. logn (k+1) – 1
137.

Which of the following is true?

A. larger the order of B-tree, less frequently the split occurs
B. larger the order of B-tree, more frequently the split occurs
C. smaller the order of B-tree, more frequently the split occurs
D. smaller the order of B-tree, less frequently the split occurs
Answer» A. larger the order of B-tree, less frequently the split occurs
138.

In a max-heap, element with the greatest key is always in the which node?

A. Leaf node
B. First node of left sub tree
C. root node
D. First node of right sub tree
Answer» C. root node
139.

The worst case complexity of deleting any arbitrary node value element from heap is

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

Heap can be used as

A. Priority queue
B. Stack
C. A decreasing order array
D. Normal Array
Answer» A. Priority queue
141.

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. none
Answer» A. 2
142.

An array consists of n elements. We want to create a heap using the elements. The time complexity of building a heap will be in order of

A. O(n*n*logn)
B. O(n*logn)
C. O(n*n)
D. O(n *logn *logn)
Answer» B. O(n*logn)
Chapter: Non Linear Data Structures - Graphs
143.

Which of the following statements for a simple graph is correct?

A. Every path is a trail
B. Every trail is a path
C. Every trail is a path as well as every path is a trail
D. Path and trail have no relation
Answer» A. Every path is a trail
144.

For the given graph(G), which of the following statements is true?

A. G is a complete graph
B. G is not a connected graph
C. The vertex connectivity of the graph is 2
D. none
Answer» C. The vertex connectivity of the graph is 2
145.

What is the number of edges present in a complete graph having n vertices?

A. (n*(n+1))/2
B. (n*(n-1))/2
C. n
D. Information given is insufficient
Answer» B. (n*(n-1))/2
146.

The given Graph is regular.

A. True
B. False
C. none
D. none
Answer» A. True
147.

A connected planar graph having 6 vertices, 7 edges contains regions.

A. 15
B. 3
C. 1
D. 11
Answer» B. 3
148.

If a simple graph G, contains n vertices and m edges, the number of edges in the Graph G'(Complement of G) is

A. (n*n-n-2*m)/2
B. (n*n+n+2*m)/2
C. (n*n-n-2*m)/2
D. (n*n-n+2*m)/2
Answer» A. (n*n-n-2*m)/2
149.

Which of the following properties does a simple graph not hold?

A. Must be connected
B. Must be unweighted
C. Must have no loops or multiple edges
D. Must have no multiple edges
Answer» A. Must be connected
150.

What is the maximum number of edges in a bipartite graph having 10 vertices?

A. 24
B. 21
C. 25
D. 16
Answer» C. 25

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.