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

How can we do this?
retagged by

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

2 votes
2 votes
1 answer
1
sh!va asked Jul 23, 2016
436 views
Given an array of integers, update the index with multiplication of previous and next integers, e.g.Input: 2 , 3, 4, 5, 6Output: 2*3, 2*4, 3*5, 4*6, 5*6 Please suggest ...
0 votes
0 votes
0 answers
3
Deepalitrapti asked Sep 1, 2018
814 views
0 votes
0 votes
1 answer
4
Desert_Warrior asked May 16, 2016
591 views
#include<stdio.h #include<stdlib.h int main() { char s[] = "Opendays2012"; int i = 0; while(*(s++)) i++; printf("%d",i); return 0; }(a) Segmentation Fault (b) Compile Err...