Skip to content

Commit a7448a7

Browse files
committed
Big O notation comments added
1 parent 22c14ad commit a7448a7

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

BubbleSort.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import time # To help us visualize this algorithm step by step
22

3+
'''
4+
Worst Case Time Complexity [ Big-O ]: O(n^2)
5+
6+
Best Case Time Complexity [Big-omega]: O(n)
7+
8+
Average Time Complexity [Big-theta]: O(n^2)
9+
10+
Space Complexity: O(1)
11+
'''
12+
313
# Based off of Geeks for Geeks Bubble sort example
14+
# Another source: https://www.studytonight.com/data-structures/bubble-sort
415
def BubbleSort(data, drawDataArray, sortSpeedTime):
516
# Traverse through all array elements
617
for _ in range(len(data)-1):

MergeSort.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import time # To help us visualize this algorithm step by step
22

3+
'''
4+
Worst Case Time Complexity [ Big-O ]: O(n*log n)
5+
6+
Best Case Time Complexity [Big-omega]: O(n*log n)
7+
8+
Average Time Complexity [Big-theta]: O(n*log n)
9+
10+
Space Complexity: O(n)
11+
'''
12+
# Based off of Geeks for Geeks Bubble sort example
13+
# Another source: https://www.studytonight.com/data-structures/merge-sort#
314
def MergeSort(data, drawDataArray, sortSpeedTime):
415
MergeSort2(data,0, len(data)-1, drawDataArray, sortSpeedTime)
516

QuickSort.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import time # To help us visualize this algorithm step by step
22

3+
'''
4+
Worst Case Time Complexity [ Big-O ]: O(n^2)
5+
6+
Best Case Time Complexity [Big-omega]: O(n*log n)
7+
8+
Average Time Complexity [Big-theta]: O(n*log n)
9+
10+
Space Complexity: O(n*log n)
11+
'''
312

413
# Based off of Geeks for Geeks Bubble sort example
14+
# Another source: https://www.studytonight.com/data-structures/quick-sort
515
def QuickSort(data, low, high, drawDataArray, sortSpeedTime):
616

717
#Base Case

0 commit comments

Comments
 (0)