edited by
31,716 views
56 votes
56 votes

The average number of key comparisons required for a successful search for sequential search on $n$ items is

  1. $\frac{n}{2}$
  2. $\frac{n-1}{2}$
  3. $\frac{n+1}{2}$
  4. None of the above
edited by

8 Answers

3 votes
3 votes

MOST OF THE STUDENTS ARE CONFUSED ABOUT RESPECTIVE PROBABILITIES FOR EACH RANDOM VARIABLE.

HERE I HAVE TRIED TO EXPLAIN HOW WE CAME TO “I/n” PROBABILITY FOR EACH RANDOM VARIABLE.

NOTE: USE CONDITIONAL PROBABILITY.

😎

2 votes
2 votes
sequential search can be applied on both sorted and unsorted array.

for(i=0;i<n;i++)

{{ if (a[i]==target)

return i;}

return -1;

}

suppose array is 9 6 5 0 8 2

best case if we have to search 9.  comparsion =1

worst case if we have to search 2   comparison =6

average=(6+1)/2

so for n the key comparison will be (n+1)/2
0 votes
0 votes
I do this question in another way

Supposed we have n  elements  in  an array
 
Now the qn is asked for success ful search ,ok

Now suppose our key elements is store at index 0 then the number of search is 1

And again supposed our key elements is store at index 1 then number of successful search is 2

And again supposed our key elements is store at index 2then number of successful search is 3

Now suppose if our element is store at last position then our number of successful search is n


Now examine fully
The total number of success full search(for all elements stored in an array) is:
1+2+3+4+.......n


That the summation comes to [n(n+1)]/2
According to summation of n natural number




Ok

But in the qn it is asked about average
So we need to divide it by n

So[ n(n+1)/2]/2

That's equal to ( n+1)/2



I think u got it way   


Reply me that my answer(way) is correct  or not
–1 votes
–1 votes
ans is D
Answer:

Related questions

35 votes
35 votes
6 answers
1
Kathleen asked Oct 9, 2014
12,649 views
Relative mode of addressing is most relevant to writing:Co – routinesPosition – independent codeShareable codeInterrupt Handlers
21 votes
21 votes
7 answers
3
Kathleen asked Oct 4, 2014
18,477 views
Algorithm design technique used in quicksort algorithm is?Dynamic programmingBacktrackingDivide and conquerGreedy method
33 votes
33 votes
5 answers
4