Algorithms Flashcards
1
Q
Bubble Sort Algorithm
A
- Start from the first index and compare the the first two elements
- If the first element is smaller, swap them
- Repeat this comparison for the same element until you haven’t swapped it
- Repeat from step 1
2
Q
Bubble Sort Time Complexity
A
O(n^2)
3
Q
Bubble Sort Space Complexity
A
O(1)