in Algorithms retagged by
491 views
0 votes
0 votes
Given an Unsorted array, Find maximum in less than O(n) time?

How can we do this?
in Algorithms retagged by
491 views

5 Comments

It's not possible - you'll have to look at every element once so the lower bound for this is $\Omega(n)$.
1
1
@goxul it should take $\Theta (n)$ and not $\Omega (n)$ to find maximum and minimum as we always have to search through all numbers.
0
0

$\Theta(n)$ also implies that $\Omega(n)$ holds, @Swapnil Naik

0
0

Yes, but Θ(n) would be more appropriate for a given condition.

0
0
Bubble Sort won't be right because it will take at least O(n) time right? Am I doing anything wrong here?
0
0

1 Answer

0 votes
0 votes

I think a simple looping through the array once is enough

 FindMax( A[] ):
   max=A[0]
   for i in A:
     if(i>max):
       max=i
   return max

 

Related questions

0 votes
0 votes
0 answers
3
Deepalitrapti asked in Algorithms Sep 1, 2018
877 views
Deepalitrapti asked in Algorithms Sep 1, 2018
877 views