The element being searched for is not found in an array of
100 elements. What is the average number of comparisons
needed in a sequential search to determine that the element
is not there, if the elements are completely unordered?

Answers were Sorted based on User's Feedback



The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / ntrphanikumar

100 comparisions

since element is not there and the data is unordered we need
to compare with each and every element

Is This Answer Correct ?    46 Yes 6 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / tarzan

Answer i think is

u require 1,2,3,...,100(max) to search an element because it
is unsorted
i assume it to be random seq of number so we hav to search
until we find the required no
so if all input ie search request is a hit then avg is
50.5=~51 (1+2+..+100/(2*100))
and if search has misses den worst is de case i.e mean will
shift towards 100 but always less than 100 bcoz it is
unrealistic to say de search is alwayz miss

Is This Answer Correct ?    23 Yes 2 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / pavan

100

Is This Answer Correct ?    18 Yes 4 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / mounesh badiger

we have to check all the elements of the array.so average is
n(size of array)

Is This Answer Correct ?    14 Yes 3 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / vidhun s

yes.we need 100 comparisons.

Is This Answer Correct ?    13 Yes 4 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / poonam

IN sequential search (average case =[1/2(best case)+(wrost case)])...its the formula to calculate the average case of sequential search ...
so best case is when we found the element in first comparison.
worst case is when we found element in 100 comparison.
average case is =1/2(1+100)
ans would be 50.5

Is This Answer Correct ?    11 Yes 5 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / siya

100 comparisons

Is This Answer Correct ?    7 Yes 3 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / tek002

The question is asking for the average number of
comparisons, not the particular realization... On average
you need 50 comparisons since the element you are searching
could just as likely be at the end of the array, as in the
beginning of the array. (for a brute force sequential
search)

If you really want to be fancy, you can actually do it with
10 (sqrt(N)) steps. Since a comparison search is an oracle
based search, you can implement the Grover's Algorithm
which is a unsorted database searching algorithm which is
the best known oracle based search for unsorted databases
(in fact is is provably the best oracle based search for
unsorted arrays).

Is This Answer Correct ?    3 Yes 4 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / shailesh pratapwar

The avrage case complexity of any linear search alogrithm is
n/2.
So we need 50 comparisons to search in 100 elements.

Is This Answer Correct ?    1 Yes 2 No

The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / pankaj

(sum of all 1 to 100) - (sum of given numbers)= number missing
for this no comparison required

Is This Answer Correct ?    4 Yes 20 No

Post New Answer

More Data Structures Interview Questions

How do you declare A pointer to array of three chars

0 Answers  


Are duplicates allowed in list?

0 Answers  


Explain the common uses of tree database.

0 Answers  


what is the biggest advantage of linked lists?

0 Answers  


Explain what is the type of the algorithm used in solving the 8 queens problem?

0 Answers  






What do you mean by spanning tree?

0 Answers   TCS,


Are dictionaries mutable?

0 Answers  


What is stable sorting?

0 Answers  


Can treemap key null?

0 Answers  


Can arraylist shrink?

0 Answers  


Which sort is stable?

0 Answers  


Which sorting is worst?

0 Answers  


Categories