(A) Push
(B) Pop
(C) Top
(D) First
Tag: Data Structures and Algorithms Mcq
What requirement is placed on an array, so that binary search may be used to locate an entry?
(A) The array elements must form a heap
(B) The array must have at least 2 entries
(C) The array must be sorted
(D) The array size must be a power of two
Here is an array of ten integers: 5 3 8 9 1 7 0 2 6 4 The array after the FIRST iteration of the large loop in a selection sort (sorting from smallest to largest).
(A) 0 3 8 9 1 7 5 2 6 4
(B) 2 6 4 0 3 8 9 1 7 5
(C) 2 6 4 9 1 7 0 3 8 5
(D) 0 3 8 2 6 4 9 1 7 5
In complete binary tree the bottom level is filled from?
(A) Left to right
(B) Right to left
(C) Not filled at all
(D) None of the above
Which of the following statement is NOT correct about find operation?
(A) 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
(B) 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
(C) Initially each set contains one element
(D) Initially each set contains one element and it does not make sense to make a tree of one node only
Which of the following statement is correct about find(x) operation?
(A) A find(x) on element x is performed by returning exactly the same node that is found
(B) A find(x) on element x is performed by returning the root of the tree containing x
(C) A find(x) on element x is performed by returning the whole tree itself containing x
(D) A find(x) on element x is performed by returning TRUE
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:
(A) 16, 18, 20, 22, 24, 28, 30
(B) 16, 20, 18, 24, 22, 30, 28
(C) 16, 24, 18, 28, 30, 20, 22
(D) 16, 24, 20, 30, 28, 18, 22
Suppose that a selection sort of 100 items has completed 42 iterations of the main loop. How many items are now guaranteed to be in their final spot (never to be moved again).
(A) 21
(B) 41
(C) 42
(D) 43