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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is map a data structure?

490


In what areas do data structures are applied?

539


What is the quickest sorting algorithm?

544


What is the minimization factor and time complexity of b-tree?

697


What is 2 dimensional linked list?

590






What are the types of map?

452


Which is best book for data structures?

522


How many types of search algorithms are there?

492


What are the tasks performed during postorder traversal?

536


What is modcount in hashmap?

495


What is the time complexity of arrays sort?

467


How to copy an array into another array?

497


Explain circular linked list?

530


Describe tree database. Explain its common uses.

553


What data structure does a binary tree degenerate?

448