+ 5
How do you find the largest and the smallest numbers in unsorted array
using predefined function is not allowed use any programming language
4 ответов
+ 11
just take an info about bubble sort and you'll learn sth😄
+ 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
+ 2
Python3 code:
https://code.sololearn.com/c8tgb5bo8Y80/?ref=app
+ 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