Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

EPT-TEST-18 (DS, Array, Graph traversal, Hashing)

TOTAL 15 QUESTIONS

MCQ 2-Marks (+2 , -0.66) (Medium)


Q1) Suppose you are given an array S[1...n] ,and a procedure
reverse(S,i,j) which reverses the order of elements in S between
positions i and j (both inclusive). What does the following
sequence do, where 1<k<=n

1. reverse(S,1,k−1)
2. reverse(S,k,n)
3. reverse(S,1,n)
4. reverse(S,1,n)
5. reverse(S,k,n)
6. reverse(S,1,k−1)

A.Rotates S left by k positions


B.Leaves S unchanged
C.Reverses all elements of S
D.Rotates S right by 2k-1 positions

MCQ 2-Marks (+2, -0.66) (Hard)

Q2) An inversion in an array a is a pair of array indices (i, j) such


that i < j but a[i]> a[j]. What is the maximal number of inversions
that can be eliminated by the following program fragment?

AnyType tmp = a [5] ;


a[5] = a[10] ;
a[10] = temp;
A.7 B.8 C.9 D.10

MCQ 2-Marks (+2, -0.66) (Hard)


Q3) Consider an array A[1...n]. It consists of a permutation of
numbers 1....n.

Now compute another array B[1...n] as follows: B[A[i]]:=i for all i.


Which of the following is true ?

A. B will be a sorted array


B. B is a permutation of array A
C. Doing the same transformation twice will not give the same
array.
D. B is not a permutation of array A

NAT 2-Marks (+2, 0) (Medium)


Q4) The following program shows some operations on the 2
dimension array then what is the output of the code? [ Consider
the size of int as the 4 bytes ]
MCQ 1-Mark (+1, -0.33) (Easy)
Q5) An array A of dimensions n∗n is defined as follows:
A[i,j ]= (−1)(i+j)(i∗j), for all i,j, where 1≤i≤n; 1≤j≤n;
The sum of the diagonal elements of the array A is ?

A. 0 B. n(n+1)(2n+1)/6 C. (n^2-n)/2 D. (n^2+n)/2

MSQ 2-Mark (+2, -0) (Medium)


6) There are several factors that affect the efficiency of lookup
operations in a hash table. Which of the following is one of those
factors?

A.Number of elements stored in the hash table

B.Size of elements stored in the hash table

C.Number of buckets in the hash table

D.Quality of the hash function.

MCQ 1-Mark (+1, -0.33) (Easy)


Q7) Two matrices M1 and M2 are to be stored in arrays A and B
respectively. Each array can be stored either in row-major or
column-major order in contiguous memory locations. The time
complexity of an algorithm to compute M1×M2 will be

A. best if A is in row-major order and B is in column-major order


B. best if both are in row-major order
C. independent of storage scheme
D. best if both are in column-major order.
MCQ 2-Marks (+2, -0.66) (Medium)
8)Which of the following statements are TRUE?

i)Suppose we do a DFS on a directed graph G. If we remove all of


the back edges found, the resulting graph is now acyclic.

ii)Both DFS and BFS require Big-Omega(V) storage for their


operation. (That is, for working storage, above and beyond the
storage needed to represent the input.)

iii) A depth-first search of a directed graph always produces the


same number of tree edges (i.e. independent of the order in
which the vertices are provided and independent of the order of
the adjacency lists)

A. i and ii B. ii and iii C. iii and i D. i, ii and iii

MCQ 2-Marks (+2, -0.66) (Hard)

9)Consider a hash table with m slots that uses chaining for


collision resolution. The table is initially empty. What is the
probability that after 4 keys are inserted that at least a chain of
size 3 is created? (Assume simple uniform hashing is used)

A. 1/(m^2) B. (m-1)/ m^3 C. (4m-3)/ m^3 D. 3/m


MSQ 2-Marks (+2 , 0) (Medium)
10) Which of the following is not a valid BFS Traversal for the
following graph.

A. A,B,F,H,G,C,E,D
B. F,A,G,H,E,B,C,D
C. D,E,H,C,F,B,G,A
D. G,A,F,C,E,B,H,D
MSQ 1-Mark (+1, -0) (Medium)
11) Which of the following are applications for DFS when we have
an unweighted directed graph at hand.

A. Single source shortest path from the source vertex.


B. Topological sorting of the vertices.
C. Strongly connected components of the graph.
D. Detection of cycles in the graph.

NAT 2-Marks (+2, -0) (Medium)


12)Maximum number of BFS Traversal Possible on a BST of
height 3 is? (Root is at height 0)

NAT 2-Marks (+2, -0) (Hard)


13) Suppose you have a hash table that can hold 100 elements. It
currently stores 30 elements (in one of 30 possible different
locations in the hash table). What is the probability that your next
two inserts will cause at least one collision (assuming a totally
random hash function)? (round off to 2 decimal places)

MCQ 2-Marks (+2, -0) (Medium)


14)If you know you will have a maximum of 100 elements, which
is the best choice of hash table size of the following?

A. 100 B. 128 C. 131 D. 151


MCQ 2-Marks (+2,-0.66) (Medium)
15) Consider an open addressing scatter table with ten slots. For
the hash function h(x) = x mod 10, insert the keys {33, 54, 69, 70,
74, 18, 19} (in the order given) into the table. Use quadratic
probing for collision resolution. The position of 19 in the final
table is?

A. 9
B. 1
C. 3
D. Not possible because of secondary clustering

You might also like