Question 1
Match the following and choose the correct answer for the order A, B, C, D
| A. Strassen matrix multiplication | p. Decrease and Conquer |
| B. Insertion sort | q. Dynamic Programming |
| C. Guassian Elimination | r. Divide and Conquer |
| D. Floyd shortest path algorithm | s. Transform and Conquer |
r, s, p, q
r, p, s, q
q, s, p, r
s, p, q, r
Question 2
In the following C program fragment, j, k n and TwoLog_n are integer variables, and A is an array of integers. The variable n is initialized to an integer â„ 3, and TwoLog_n is initialized to the value of 2*âlog2(n)â
for (k = 3; k < = n; k++)
A[k] = 0;
for (k = 2; k < = TwoLog_n; k++)
for (j = k + 1; j < = n; j++)
A[j] = A[j] || (j % k);
for (j = 3; j < = n; j++)
if (!A[j]) printf("%d", j);
The set of numbers printed by this program fragment is
{m | m †n, (â i) [m = i!]} Here i! mean factorial of i
{m | m †n, (â i) [m = i2]}
{m | m †n, m is prime}
Last print never executes
Question 3
An n x n array v is defined as follows:
v[i, j] = i-j for all i, j, 1 <= i <= n, 1 <= j <= nThe sum of the elements of the array v is
0
n-1
n2 - 3n + 2
n2 (n+1)/2
Question 4
X, Y and Z are closed intervals of unit length on the real line. The overlap of X and Y is half a unit. The overlap of Y and Z is also half a unit. Let the overlap of X and Z be k units. Which of the following is true?
k must be 1
k must be 0
k can take any value between 0 and 1 (d) None of the above
None of the above
Question 5
Suppose you are given an array s[1..n] and a procedure reverse (s, i, j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence do, where 1 <= k <= n:
reverse(s, 1, k) ;
reverse(s, k + 1, n);
reverse(s, l, n);
Rotates s left by k positions
Leaves s unchanged
Reverses all elements of s
None of the above
Question 6
void fun(int arr[], int n)
{
for (int i = 0; i < n; i+=2)
{
if (i>0 && arr[i-1] > arr[i] )
swap(&arr[i], &arr[i-1]);
if (i<n-1 && arr[i] < arr[i+1] )
swap(&arr[i], &arr[i + 1]);
}
}
Question 7
Match the following
List-I
A. Primâs algorithm for minimum spanning tree
B. Floyd-Warshall algorithm for all pairs shortest paths
C. Mergesort
D. Hamiltonian circuit
List-II
1. Backtracking
2. Greedy method
3. Dynamic programming
4. Divide and conquer
Codes: A B C D
(a) 3 2 4 1
(b) 1 2 4 3
(c) 2 3 4 1
(d) 2 1 3 4
a
b
c
d
Question 8
Let an represent the number of bit strings of length n containing two consecutive 1s. What is the recurrence relation for an?
anâ2 + anâ1 + 2nâ2
anâ2 + 2anâ1 + 2nâ2
2anâ2 + anâ1 + 2nâ2
2anâ2 + 2anâ1 + 2nâ2
Question 9
Given below are some algorithms, and some algorithm design paradigms.
List-I
A. Dijkstraâs Shortest Path
B. Floyd-Warshall algorithm to compute all pairs shortest path
C. Binary search on a sorted array
D. Backtracking search on a graph
List-II
1. Divide and Conquer
2. Dynamic Programming
3. Greedy design
4. Depth-first search
5. Breadth-first search
Match the above algorithms on the left to the corresponding design paradigm they follow Codes:
A B C D
(a) 1 3 1 5
(b) 3 3 1 5
(c) 3 2 1 4
(d) 3 2 1 5
a
b
c
d
Question 10
Suppose c = â©c[0], ... , c[k â 1]âȘ is an array of length k, where all the entries are from the set {0, 1}. For any positive integers a and n, consider the following pseudocode.
DOSOMETHING (c, a, n)
z â 1
for i â 0 to k â 1
do z â z2 mod n
if c[i] = 1
then z â (z Ă a) mod n
return z
If k = 4, c = â©1, 0, 1, 1âȘ, a = 2 and n = 8, then the output of DOSOMETHING(c, a, n) is ____________.
0
1
2
3
There are 49 questions to complete.