+ 5

How do you find the largest and the smallest numbers in unsorted array

using predefined function is not allowed use any programming language

21st Apr 2019, 8:16 AM
Michael Mamo
Michael Mamo - avatar
4 Answers
+ 11
just take an info about bubble sort and you'll learn sth😄
21st Apr 2019, 3:05 PM
I‘m SarahđŸŒč
I‘m SarahđŸŒč - avatar
+ 10
Smallest number = first number in the array Iterate over the array Whenever you find a smaller number, update the variable that holds the smallest number Same with largest number Variation: use a pointer instead of a variable
21st Apr 2019, 8:21 AM
Anna
Anna - avatar
21st Apr 2019, 8:23 AM
Kartik
Kartik - avatar
+ 1
Compare arr[i] < arr[i + 1], if the comparison is true, swap the adjacent elements. Then the biggest element bubbles up the index, hence BubbleSort
7th Jul 2019, 2:45 PM
William Mabotja
William Mabotja - avatar