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

On clicking a node in a tree, all the adjacent edges are turned on. Calculate min of clicks such that all the edges are turned on.

600


Which interfaces are implemented by concurrentskiplistset?

477


What does simulation of queues mean?

564


What are the standard ways in which a graph can be traversed?

476


What is binary search in data structure?

448






How efficient is bubble sort?

496


Explain the uses of b+ tree.

527


What is the complexity of bubble sort?

481


Define parent node?

541


Why is arraylist used?

474


Is it possible to make an array volatile in java?

503


What are different dynamic memory allocation technique in c.

526


How would you check if a binary tree is BST or not ? Write a program.

508


Why is arraylist not thread safe?

499


Check if duplicates exist in an array of N which has range 1 to N.

540