CS-2002 Question Paper With Solutions

Q. 35 Consider the following algorithm for searching for a given number x in an unsorted array A[1…..n] having n distinct values:

   1. Choose an i uniformaly at random from 1..... n;
   2. If A[i] = x then Stop else Goto 1;

Assuming that x is present in A, what is the expected number of comparisons made by the algorithm before it terminates ?

CS-2002 Question Paper With Solutions

Answer: (A)

Explanation:

CS-2002 Question Paper With Solutions

Learn More:   Gate CS-2004 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here