retagged by
648 views
1 votes
1 votes

Minimum number of comparisons to find minimum and maximum of 100 numbers ??

Average number of comparisons to find minimum and maximum of 100 numbers ??

Maximum number of comparisons to find minimum and maximum of 100 numbers ??

Find all the 3 cases in detailed manner which should work for all inputs.

retagged by

1 Answer

1 votes
1 votes

1)minimum no of comparisions use

min heap tree minimum element only '1' comparision-----if we use max heap ,find max element is only '1' comparision

3)maximum element 100 comaprisions in min heap tree.(we don't know where max element present)

minimum element 100 comparisions in max heap tree.

2)for average no of comparisions use avl tree.

min and max element requires log(100)+1=8 comparisions.

3)we can search max element in only '1' comparision using max heap tree.

if we consider constructio for tree also it requires o(nlogn)=100*log(100)=700.

no of comparisions   =700+cost for searching particular element(max or min)

finally prefer binary search tree(avl tree) to search any element in only o(logn) comparisions

Related questions

0 votes
0 votes
3 answers
1
pankaj_vir asked Oct 10, 2018
1,247 views
What is the total number of comparisons needed in the best case to find minimum and maximum of $300 $ elements?
5 votes
5 votes
1 answer
2
shaurya vardhan asked Nov 4, 2017
8,156 views
You are given an array of 64 elements, minimum number of comparisons required to find out second largest element among all will be _______.