← Back
Find Minimum and Maximum in an Array
Given an array of integers, find the minimum and maximum elements.
Algorithm
- Initialize min and max variables.
- Iterate through the array:
- If the current element is less than min, update min.
- If the current element is greater than max, update max.
- Return or print the min and max values.
Time Complexity
The time complexity of this algorithm is O(n), where n is the number of elements in the array.
Array: []