Bubble Sort Notes Day 1 Flashcards

You may prefer our related Brainscape-certified 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you implement bubble sort?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly