Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the average number of comparisons needed in a
sequential search to determine the position of an element in
an array of 100 elements, if the elements are ordered from
largest to smallest?

Answer Posted / nilavalagan

The element may be found at any place in the array.

Supposing that the element is in 1st position, no.of comparison = 1;
Element is in 2nd position, no.of comparison = 2;

In the same way,
for the element present in 100th positionn no.of comparison = 100;

Total no.of comparison = 1+2+3+....+100

Average no.of comparison = (1+2+3+..+100)/100

= (100*101)/2*100
(Remember n(n+1)/2)
=101/2 = 50.5

In general = (n+1)/2; if there are n elements.

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to reverse a linked list iterative algorithm?

871


Explain the internal working of a hash map?

911


Why do we need algorithm?

837


Explain binary searching and Fibinocci search?

899


Is hashset thread safe?

920


How many types of lists are there?

963


What is an example of an algorithm?

849


What is the use of prototype?

853


What is thread and types of thread?

893


Does arraylist extend list?

865


What is perfect binary tree?

794


Differentiate between list and map.

969


Explain what is B-tree?

978


Can nsarray contain nil?

777


What is the difference between Array and Array List ? Explain in brief with example.

915