Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What is the maximum of the array [4, 1, 3, 9, 7]?
Look for the largest number.
How would you initialize the maximum when finding it in an array?
Start with the first element as a reference.
What is the time complexity to find the maximum in an array?
Think about how many elements you need to check.
True or False: A recursive approach can be faster than an iterative approach for finding maximum.
Consider the function calls involved.
You are given an array of integers with both positive and negative values. Can you devise a method to find the maximum in linear time?
Remember the overall structure of your iterative solution.
Consider an array that includes multiple maximum elements. How would you modify your algorithm to find out how many times the maximum occurs?
You will need to include a conditional check for equality.
5 more questions in this section. Enroll free to practise them all.
Enroll free