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

Can we change the size of an array at run time?

611


How do you find the size of an arraylist?

496


Can we insert null in list?

588


What are hashmaps good for?

591


How can someone display singly linked list from first to last?

578






List some applications of queue data structure.

597


What do you mean by breadth first search (bfs)?

706


What is data and its type?

571


What are sorting algorithms used for?

619


What is a Queue? Explain its operation with example?

607


Which is the parent class of sortedset class?

656


Questions related to arrays, such as given a 2 integer array, find the common elements.

602


What are the properties of an algorithm?

588


What is dynamic data structure?

850


Define in brief an array.

609