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

I am given a sequential algorithm that does a routine search
on an unordered list. N = 20.
The probability that the value x does NOT appear in the list
is exactly 60%, and the probability that x DOES appear is 40%.
The 3 questions that I could not get were:

A) What is the avg number of element comparisons performed
when n = 20 and x does NOT appear in the List.
(my answer was 20, is this correct?)

B) What is the avg number of element comparisons peformed
when n = 20 and x DOES appear in the list?

C) What is the avg number of element comparisons performed
when n = 20. This should be a single number answer they said.

Answer Posted / guest

a) 20 worst case scenario so it will take N comparison
b) 10 average case scenario N/2 omparisons
c) 16 (20*0.6 + 10*0.4 = 16) as stated above

Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between array list and vector list?

851


Give the example of validating the parenthesis of expression using stack.

976


How do you access the values within an array?

1010


Is list same as array?

774


Write an algorithm to find middle element in the linked list.

865


What is static array?

907


What is the need for priority queue?

936


What is the difference between a stack and an array?

996


Explain the terms base case, recursive case, binding time, run-time stack and tail recursion.

829


Can hashmap have same key?

828


How can you insert a node in a random location of the linked list?

842


What do you mean by hash function?

867


What is a multiset table?

811


Is linked list faster than array?

793


Which is the parent class of enumset class?

906