Array list: ⇒ 2, 5, 4, 8, 3
Sort the array from lowest number to greatest number using bubble sort.
First pass:
2 , 5 , 4 , 8 , 3
2 , 4 , 5 , 8 , 3 ⇒⇒⇒ Swap since 5 > 4
2 , 4 , 5 , 8 , 3
2 , 4 , 5 , 3 , 8 ⇒⇒⇒ Swap since 8 > 3
∴ The index of the number 8 after the first pass = 5