CS301 Quiz-4 by Vu Topper RM
CS301 Quiz-4 by Vu Topper RM
If whole data is given to construct the min heap, then which of the
following is true?
A. Insert method is appropriate for construction
B. Both Insert and BuildHeap method are equally appropriate
C. BuildHeap method is appropriate for construction
D. Both Insert and Buildheap methods are inappropriate.
The scenario “If Ali is brother of Asif and Asif is brother of Uzma then
Ali is brother of Uzma” is the example of ___________ property.
Transitive
Which of the following heap method lowers the value of key at position
‘p’ by the amount ‘delta’?
increaseKey(p,delta)
Suppose there are a set of fruits and a set of vegetables. Both sets are
______________ sets.
Disjoint
In min heap, if there are 100 elements in a heap and we perform 100
deleteMin operations then we will get the elements in _________.
Ascending order
For a perfect binary tree of height 4. What will be the sum of heights of
nodes?
31
If a tree has 20 edges/links, then the total number of nodes in the tree
will be :
19
For a perfect binary tree of height h, having N nodes, the sum of heights
of nodes is _____________.
N-(H+1)
Median is __________.
A. K = N * 3
B. K = N / 3
C. K = N * 2
D. K = N /2
A perfect binary tree is constructed using 131071 nodes then what will
be the maximum height of that binary tree?
A. 14
If the bottom level of a binary tree is not completely filled, depicts that
the tree is not a _______.
A. Expression tree
B. Threaded binary tree
C. Complete Binary tree Page 323
D. Perfectly complete Binary tree
When a complete binary tree, represented by an array then for any array
element at position i, the parent is at position ______ .
A. 2i
B. 2i-1
If there are 56 internal nodes in a binary tree then how many external
nodes this binary tree will have?
A. 55
B. 56
C. 57 Page 303
D. 58
If min heap is implemented through array, then the first element of heap
will be will be stored ________.
A. 0
B. 1
C. 2
D. 3
In which of the following tree, parent node has key greater than or equal
to its both children?
A. Max heap
B. Binary search tree
C. Threaded Binary tree
D. Complete Binary tree
If the bottom level of a binary tree is NOT completely filled, depicts that
the tree is NOT a ----------
A. Expression tree
B. Threaded binary tree
C. Complete Binary tree Page 323
D. Perfectly complete Binary tree
See the below code and fill the appropriate answer for ? sign.
void fastInorder(TreeNode* p)
{
while((p=nexInorder(p)) != ? )
cout << p->getInfo();}
A. RTH
B. LTH
C. Dummy
D. RootNode
A Threaded Binary Tree is a binary tree in which every node that does
not have a right child has a THREAD (in actual sense, a link) to its
__________ successor.
A. Inorder
B. Preorder
C. Postorder
D. Levelorder
If there are N external nodes in a binary tree then what will be the no. of
internal nodes in this binary tree?
A. N
B. N-1
C. N+1
D. N+2
In AVL tree during insertion, a single rotation can fix the balance in
cases _________ and 4.
A. 1 Page 239
B. 2
C. 3
D. 4
We are given N items to build a heap of items , this can be done with
_____ successive inserts.
A. N
B. N-1
C. N+1
D. N*2
While building Huffman encoding tree the new node that is the result of
joining two nodes has the frequency.
A. Equal to the small frequency
B. Equal to the greater frequency
C. Equal to the sum of the two frequencies
D. Equal to the difference of the two frequencies
If there are __________ nodes in an AVL tree, its levels will be roughly
as Log2(10 million).
The total number of nodes on 10th level of a perfect binary tree are :
256
512
1024
Can't be determined
The total number of nodes on 5th level of a perfect binary tree are :
15
16
31
32
If the height of a perfect binary tree is 4. What will be the total number
of nodes in it?
15
If a tree has 50 nodes, then the total edges/links in the tree will be :
49
► Stack
► Queue
► Both of these
► None of these
► Binary Tree
► None of these
Searching an element in an AVL tree take maximum _______ time (where n is no. of nodes in AVL tree),
► Log2(n+1)
► Log2(n+1) -1
► 1.44 Log2n
► 1.66 Log2n
Suppose that we have implemented a priority queue by storing the items in a heap. We are now executing
a reheapification downward and the out-of-place node has priority of 42. The node’s parent has a priority
of 72, the left child has priority 52 and the node’s right child has priority 62. Which statement best describes
the status of the reheapification.
► The next step will interchange the two children of the out-of-place node.
► The next step will swap the out-of-place node with its parent.
► The next step will swap the out-of-place node with its left child.
►7654321
►7362145
►7643521
►7364251
► Reflexive
► Symmetric
► Transitive
► Associative ok
► Constant
► Polynomial
► Exponential
► A major use of table is in databases where we build and use tables for keeping information.
► Sorted
► Unsorted
► Heterogeneous
► Random
Which of the following statement is NOT true about threaded binary tree?
► 11,22,33,44,55,66
► 11,22,33,44,66,55
► 11,22,33,66,44,55
► 11,22,66,33,44,55
► 4,6,7,5
► 6,7,5,4
► 4,5,6,7
► 4,6,5,7
Suppose we are sorting an array of eight integers using quick sort, and we have just finished the first
partitioning with the array looking like this:
2 5 1 7 9 12 11 10
Which statement is correct?
Which formula is the best approximation for the depth of a heap with n nodes?
► log (base 2) of n
► The number of digits in n (base 10), e.g., 145 has three digits
►n
Suppose you implement a Min heap (with the smallest element on top) in an array. Consider the different
arrays below; determine the one that cannot possibly be a heap:
While joining nodes in the building of Huffman encoding tree if there are more nodes with same
frequency, we choose the nodes _______.
► Randomly
A binary tree with 33 internal nodes has _______ links to internal nodes.
► 31
► 32
► 33
► 66
Which traversal gives a decreasing order of elements in a heap where the max element is stored at the
top?
► post-order
► inorder
What requirement is placed on an array, so that binary search may be used to locate an entry?
► Linked List
► Stack
► Queue
► Tree
► ab+c*d-
► abc*+d-
► abc+*d-
► (abc*)+d-
► Arrays
► Lists
► Both of these
► None of these
► Binary Tree
► Parse Tree
► AVL Tree
► data[1]
► data[n-1]
► data[n]
► data[2*n+1]
► increaseKey(p,delta)
► decreaseKey(p,delta)
► preculateDown(p,delta)
► remove(p,delta)
► Electrical connectivity
► Set of people
► <= relation
► Set of pixels
► Log10 N levels
► Log2 N levels
► N / 2 levels
► N x 2 levels
► Heap sort
► Selection sort
► Insertion sort
► Bubble sort
► n-1
► n log n
► n2
►1
► A find(x) on element x is performed by returning exactly the same node that is found.
► A find(x) on element x is performed by returning the root of the tree containing x.
► A find(x) on element x is performed by returning the whole tree itself containing x.
► A find(x) on element x is performed by returning TRUE.
► It is not a requirement that a find operation returns any specific name, just that finds on two
elements return the same answer if and only if they are in the same set.
S=AB-C+DEF-+^
Assume that A=3, B=2, C=1, D=1, E=2, F=3
►1
►2
►0
► -1
► True
► False
► True
► False
► 1 pointer
► 2 pointers
► 3 pointers
► 4 pointers
► Neither changes
► Both change.
► Binary Tree
► Parse Tree
► AVL Tree
► Log2 (n+1) -1
► 2n
► Log2 (n) - 1
► 2n - 1
► Log (h)
► 2h+1- 1
► Log (h) - 1
► 2h - 1
► Reflexivity
► Symmetry
► Transitivity
► All of the given options
► Traversal
► Heap
► Union
► Huffman encoding
► 21
► 41
► 42
► 43
► It is not a requirement that a find operation returns any specific name, just that finds on two
elements return the same answer if and only if they are in the same set.
► One idea might be to use a tree to represent each set, since each element in a tree has the same
root, thus the root can be used to name the set.
►x y -a * b +c /
►x *y a - b c / +
►x y a * - b c / +
►x y a * - b/ + c
►0 3 8 9 1 7 5 2 6 4
►2 6 4 0 3 8 9 1 7 5
►2 6 4 9 1 7 0 3 8 5
►0 3 8 2 6 4 9 1 7 5
The arguments passed to a function should match in number, type and order with the parameters in the
function definition.
► True
► False
If numbers 5, 222, 4, 48 are inserted in a queue, which one will be removed first?
► 48
►4
► 222
►5
A Compound Data Structure is the data structure which can have multiple data items of same type or of
different types. Which of the following can be considered compound data structure?
► Arrays
The difference between a binary tree and a binary search tree is that ,
► a binary search tree has two children per node whereas a binary tree can have none, one,
or two children per node
► in binary search tree nodes are inserted based on the values they contain
► in binary tree nodes are inserted based on the values they contain
► none of these
► Binary Tree
► Parse Tree
► AVL Tree
► insert
► add
► update
► preculateDown
► Log10 N levels
► Log2 N levels
► N / 2 levels
► N x 2 levels
► Heap sort
► Selection sort
► Insertion sort
► Bubble sort
► 10,30,20,31,40,50,80,60,70
► 10,31,20,30,40,50,80,60,31
► 31,10,30,20,70,40,50,80,60
Which one of the following algorithms is most widely used due to its good average time,
► Bubble Sort
► Insertion Sort
► Quick Sort
► Merge Sort
(i) The last item to be added to a queue is the first item to be removed
(ii) A queue is a structure in which both ends are not used
(iii) The last element hasn’t to wait until all elements preceding it on the queue are removed
(iv) A queue is said to be a last-in-first-out list or LIFO data structure.
Which of the above is/are related to normal queues?
The maximum number of external nodes (leaves) for a binary tree of height H is _________
► 2H
► 2H +1
► 2H -1
► 2H +2
Question No: 26 ( Marks: 1 ) - Please choose one
We are given N items to build a heap , this can be done with _____ successive inserts.
► N-1
►N
► N+1
► N^2
Suppose we had a hash table whose hash function is “n % 12”, if the number 35 is already in the hash
table, which of the following numbers would cause a collision?
► 144
► 145
► 143
► 148
In case of deleting a node from AVL tree, rotation could be prolong to the root node.