Data Structure WITH PYTHON Study Materials
Data Structure WITH PYTHON Study Materials
Traversal?
Or
How to construct BFS Tree and DFS Tree for a given graph?
Or
Learn
Or
Learn
Learn
Or
What is Complete Binary Tree?
Learn
Learn
Learn
7- What are the minimum and maximum number of nodes that can be inserted
in a binary tree of given hight ‘h’?
Learn
Learn
Learn
Learn
Learn
Learn
Or
Learn
Breath First Search(BFS) has been implemented using queue data structure.
Which one of the following is a possible order of visiting the nodes in the graph
above.
(A) MNOPQR
(B) NQMPOR
(C) QMNROP
(D) POQNMR
Option: D
Solution
Option: B
Solution
The maximum possible number of iterations of the while loop in the algorithm
is_________.
Answer: 256
Solution
(A) 6
(B) 7
(C) 8
(D) 9
Option: C
Solution
Q5- Topic:- Topological Order
Answer: 6
Solution
Breadth First Search (BFS) is started on a binary tree beginning from the root
vertex. There is a vertex t at a distance four from the root. If t is the n-th vertex
in this BFS traversal, then the maximum possible value of n is ___________.
Answer: 31
Solution
Option: C
Solution
Answer: 64
Solution
The height of a tree is the length of the longest root-to-leaf path in it. The
maximum and minimum number of nodes in a binary tree of height 5 are
(A) 63 and 6, respectively
(B) 64 and 5, respectively
(C) 32 and 6, respectively
(D) 31 and 5, respectively
Option: A
Solution
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4.
Now consider that a value 35 is inserted into this heap. After insertion, the new
heap is
(A) 40, 30, 20, 10, 15, 16, 17, 8, 4, 35
(B) 40, 35, 20, 10, 30, 16, 17, 8, 4, 15
(C) 40, 30, 20, 10, 35, 16, 17, 8, 4, 15
(D) 40, 35, 20, 10, 15, 16, 17, 8, 4, 30
Option: B
Solution
Which one of the following hash functions on integers will distribute keys most
uniformly over 10 buckets numbered 0 to 9 for i ranging from 0 to 2020?
Option: C
Solution
A Young tableau is a 2D array of integers increasing from left to right and from
top to bottom. Any unfilled entries are marked with ∞, and hence there cannot
be any entry to the right of, or below a ∞. The following Young tableau consists
of unique entries.
1 2 5 14
3 4 6 23
10 12 18 25
31 ∞ ∞ ∞
Option: B
Solution
Given a hash table T with 25 slots that stores 2000 elements, the load factor α
for T is ____________.
(A) 80
(B) 0.0125
(C) 8000
(D) 1.25
Option: A
Solution
Consider the following array of elements. 〈89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6,
9, 100〉. The minimum number of interchanges needed to convert it into a max-
heap is
(A) 4
(B) 5
(C) 2
(D) 3
Option: D
Solution
While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search
tree (BST) in the sequence shown, the element in the lowest level is
(A) 65
(B) 67
(C) 69
(D) 83
Option: B
Solution
(A) 284
(B) 213
(C) 142
(D) 71
Option: C
Solution
Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T
that have exactly two children are _________.
(A) 199
(B) 200
(C) Any number between 0 and 199
(D) Any number between 100 and 200
Option: A
Solution
Q18- Topic:- Shortest Path Using BFS
Option: B
Solution
(A) 10, 8, 7, 3, 2, 1, 5
(B) 10, 8, 7, 2, 3, 1, 5
(C) 10, 8, 7, 1, 2, 3, 5
(D) 10, 8, 7, 5, 3, 2, 1
Option:- A
Solution
(A) 3, 0, and 1
(B) 3, 3, and 3
(C) 4, 0, and 1
(D) 3, 0, and 2
Option: A
Solution
Consider the directed graph given below. Which one of the following is TRUE?
Option: C
Solution
Option: A
Solution
The height of a tree is defined as the number of edges on the longest path in the
tree. The function shown in the pseudocode below is invoked as height (root) to
compute the height of a binary tree rooted at the tree pointer root.
The appropriate expression for the two boxes B1 and B2 are-
Option: A
Solution
The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23,
39, 35, 42. Which one of the following is the postorder traversal sequence of
the same tree?
Solution
A max-heap is a heap where the value of each parent is greater than or equal to
the values of its children. Which of the following is a max-heap?
(A) A
(B) B
(C) C
(D) D
Option: B
Solution
Q26- Topic:- Binary Search Tree
We are given a set of n distinct elements and an unlabelled binary tree with n
nodes. In how many ways can we populate the tree with the given set so that it
becomes a binary search tree?
(A) 0
(B) 1
(C) n!
(D) (1/(n+1)).2nCn
Option: B
Solution
int value;
}Node;
return head;
q = NULL; p = head;
q = p;
p = p->next;
_______________________________
return head;
Option: D
Solution
In a binary tree with n nodes, every node has an odd number of descendants.
Every node is considered to be its own descendant. What is the number of
nodes in the tree that have exactly one child?
(A) 0
(B) 1
(C) (n-1)/2
(D) n-1
Option: A
Solution
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in
the matrix W below is the weight of the edge {i, j}.
What is the minimum possible weight of a spanning tree T in this graph such
that vertex 0 is a leaf node in the tree T?
(A) 7
(B) 8
(C) 9
(D) 10
Option: D
Solution
Which one of the following choices gives a possible order in which the key
values could have been inserted in the table?
Option: C
Solution
How many different insertion sequences of the key values using the same hash
function and linear probing will result in the hash table shown above?
(A) 10
(B) 20
(C) 30
(D) 40
Option: C
Solution