GATE 2004 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2004

199 questions

MCQ 1991-mark 199

Questions 116–120 of 199

Q116Asymptotic Notation1 markMCQ−0.33 if wrong
Let A[1,..., n] be an array storing a bit (1 or 0) at each location, and f(m) is a function whose time complexity is θ\theta(m). Consider the following program fragment written in a C like language:
 counter = 0;
for (i = 1; i <= n; i++)
{ 
      if (A[i] == 1) 
         counter++;
      else {
         f(counter); 
         counter = 0;
      }
}
The complexity of this program fragment is

Q117Recurrence Relation1 markMCQ−0.33 if wrong
Consider a list of recursive algorithms and a list of recurrence relations as shown below. Each recurrence relation corresponds to exactly one algorithm and is used to derive the time complexity of the algorithm.

Recursive Algorithm Recurrence RelationPBinary searchl.T(n)=T(n−k)+T(k)+cnQ.Merge sortll.T(n)=2T(n−1)+1 R.Quick sortlll.T(n)=2T(n/2)+cnS.Tower of HanoilV.T(n)=T(n/2)+1\begin{array}{|l|l|l|l|}\hline \text{} & \textbf{Recursive Algorithm } & \text{} & \textbf{Recurrence Relation} \\\hline \text{P} & \text{Binary search} & \text{l.} & \text{$T(n) = T(n-k) +T(k) +cn$} \\\hline \text{Q.} & \text{Merge sort} &\text{ll.} & \text{$T(n) = 2T(n-1) + 1$ }\\\hline\text{R.} & \text{Quick sort}& \text{lll.} & \text{$T(n) = 2T(n/2) + cn$}\\\hline \text{S.} & \text{Tower of Hanoi} & \text{lV.} & \text{$T(n) = T(n/2) + 1$} \\\hline \end{array}

Which of the following is the correct match between the algorithms and their recurrence relations?

Q118Recurrence Relation1 markMCQ−0.33 if wrong
The recurrence equation

T(1) = 1
T(n) = 2T(n - 1) + n, n ≥\geq 2

evaluates to

Q119Minimum Spanning Tree1 markMCQ−0.33 if wrong
Consider the undirected graph below:
A B E C G D F 10 49 30 10 2 22 26 4 5 7 22
Using Prim's algorithm to construct a minimum spanning tree starting with node A, which one of the following sequences of edges represents a possible order in which the edges would be added to construct the minimum spanning tree?

Q120Shortest Path1 markMCQ−0.33 if wrong
Suppose we run Dijkstra's single source shortest-path algorithm on the following edge-weighted directed graph with vertex P as the source.
1 1 4 6 7 2 1 3 2 2 P Q R S T U
In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized?