Bubble Sort Notes Day 1 Flashcards
1
Q
What is bubble sort?
A
a simple sorting algorithm that repeatedly steps through an array, compares adjacent elements and swaps them if they are in the wrong order.
2
Q
how do you swap elements in an array?
A
array = [“a”, “b”, “c”, “d”] # let’s swap “a” and “b”
array[0], array[1] = array[1], array[0]
p array # => [“b”, “a”, “c”, “d”]
3
Q
How do you implement bubble sort?
A