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

the above answer of n+1/2 is correct if you assume it will
always be a successful search. you also need to take into
account the probability of the item NOT being in the list.
as such your final formula is actually

p/n * n(n+1)/2 + n(1-p) where p is the probability that the
item is in the list. That formula can be reduced ton(1-p/2)+p/2
assuming a probability of .5, you wind up with an answer of
(3n+1)/4 or ~3/4 of the list will be searched on average.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we put null value in hashmap?

868


Define outdegree of a graph?

961


How is heap sort implemented?

827


In rdbms, explain what is the efficient data structure used in the internal storage representation?

925


Differentiate between hashmap and hashtable.

1111


Do all declaration statements result in a fixed reservation in memory?

925


How can avl tree be useful in all the operations as compared to binary search tree?

840


What are the major data structures used in the following areas : network data model & hierarchical data model?

1025


What is a singletonlist?

880


Will arraylist maintain insertion order?

915


Why is quicksort so fast?

881


What are the applications of linked list?

864


Is queue fifo or lifo?

883


What are the advantage of collection classes over arrays?

890


How to get largest and smallest number in an array?

1003