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

What is map data structure?

838


Is duplicate allowed in hashmap?

1018


“int a[] = new int[3]{1, 2, 3}” – This a legal way of defining the arrays?

1145


How would you use qsort() function to sort the name stored in an array of pointers to string?

885


What is a threaded binary tree? Explain its operation with example?

1074


How would you use bsearch() function to search a name stored in array of pointers to string?

800


What does it mean to sort an array?

868


What sort does arrays sort use?

816


What is Doubly link list?

891


If you are given a choice to use either arraylist and linkedlist, which one would you use and why?

927


What are three common types of traversals?

910


What is hashing in cyber security?

846


Which sorting technique is best in worst case?

837


Write the disadvantages of separate chaining?

850


What is array and its types with example?

864