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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can hashmap have duplicate keys?

498


Explain singly linked list in short.

549


Why is quicksort unstable?

506


What are sorting algorithms used for?

529


Why do we need linked list?

446






Which data structure is applied when dealing with a recursive function?

608


What method is used to place a value onto the top of a stack?

569


What do you mean by level of the tree?

569


What is the Role of push() and pop() method?

531


What is return map?

547


Write program for Quick sort ?

598


Define ancestor and descendant ?

547


What do you mean by recursive definition?

499


Calculate the address of a random element present in a 2d array, given base address as ba.

1073


an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].

564