Created
September 3, 2018 15:34
-
-
Save jasikpark/a1169a6cb8d176a4967090b7129ad7eb to your computer and use it in GitHub Desktop.
Minmax2 code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Algorithm minMax2(A,n) | |
Input: Array A of n elements | |
Output: [min,max] | |
min <- A[0] | |
max <- A[0] | |
for i <- 1 to n-1 do | |
if A[i] < min then | |
min <- A[i] | |
else | |
if A[i] > max then | |
max <- A[i] | |
end if | |
end if | |
end for | |
return [min,max] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment