Algorithms Flashcards

1
Q

Bubble Sort Algorithm

A
  1. Start from the first index and compare the the first two elements
  2. If the first element is smaller, swap them
  3. Repeat this comparison for the same element until you haven’t swapped it
  4. Repeat from step 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Bubble Sort Time Complexity

A

O(n^2)

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

Bubble Sort Space Complexity

A

O(1)

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