retagged by
300 views
0 votes
0 votes
An unsorted list contain log(n) (base 2) distinct elements. The time complexity to find an element in this list that is neither maximum nor minimum is?
retagged by

1 Answer

Best answer
3 votes
3 votes

It will take O(1) time.

since it is given that all are distinct element so, lets say array of 5 element 

A = {4, 7, 3, 8, 10} is given,

now when you compare first 3 number 4, 7, 3 you can say that 3 is minimum and 7 is maximum where 

4 is neither minimum nor maximum, Hence using only 3 comparison means in O(1) time you can find it.

Hence, it is O(1).

selected by

Related questions

0 votes
0 votes
0 answers
2
0 votes
0 votes
1 answer
3
NeelParekh asked Jul 27, 2023
279 views
If an array is split in the form of increasing and decreasing order then what is TC to find minimum element in the array?
2 votes
2 votes
1 answer
4
h4kr asked Dec 30, 2022
472 views
What is the correct time complexity in $\theta()$ ?