Algorithms and Data Structures · Junior · Question 59 of 75

What is the complexity of finding the maximum of an unsorted array?

Explanation

Any element could be the maximum, so each one must be checked at least once. One pass with a running maximum is optimal. Sorting first would be O(n log n), slower than needed.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 59

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz