From ed31b96d2c2ae28fc9f9e3cde1eb6e4cb337d697 Mon Sep 17 00:00:00 2001 From: rickylai Date: Thu, 1 Apr 2021 19:35:58 -0700 Subject: [PATCH 01/10] Testing --- sortingalgorithm.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sortingalgorithm.py diff --git a/sortingalgorithm.py b/sortingalgorithm.py new file mode 100644 index 0000000..3d1fa11 --- /dev/null +++ b/sortingalgorithm.py @@ -0,0 +1,15 @@ +# Sorting Algorithm Visualizer +# Inspired throughout my completion in our Data Structures and Algorithm's course during university + +# Beginning with sorting algorithms we learned first in-class which is inclusive of: +# Selection Sort +# Insertion Sort +# Quick Sort +# Merge Sort +# and more to come! + +#import sorting_algorithms, time, os, sys +#os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" +#import pygame + +#testing 123 \ No newline at end of file From ff44a99fdb710d0f46ee1d22c59d9ccdde8662f9 Mon Sep 17 00:00:00 2001 From: rickylai Date: Thu, 1 Apr 2021 22:14:55 -0700 Subject: [PATCH 02/10] Algorithm Update : Selection, Insertion --- sortingalgorithm.py | 53 ++++++++++++++++++++++++++++++++++++- sortingvisualizationtool.py | 20 ++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 sortingvisualizationtool.py diff --git a/sortingalgorithm.py b/sortingalgorithm.py index 3d1fa11..642015c 100644 --- a/sortingalgorithm.py +++ b/sortingalgorithm.py @@ -12,4 +12,55 @@ #os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" #import pygame -#testing 123 \ No newline at end of file +#testing 123 + +import random, time + +class Algorithm: + def __init__(self, name): + self.array = random.sample(range(512), 512) + self.name = name + + def update_display(self, swap1=None, swap2=None): + import sorting_visualiser + + sorting_visualiser.update(self, swap1, swap2) + + def run(self): + self.start_time = time.time() + self.algorithm() + time_elapsed = time.time() - self.start_time + return self.array, time_elapsed + +# https://www.geeksforgeeks.org/selection-sort/ +# https://www.bigocheatsheet.com/ +# https://en.wikipedia.org/wiki/Selection_sort +# The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array. +class SelectionSort(Algorithm): + def __init__(self): + super().__init__("SelectionSort") + + def algorithm(self): + for i in range(len(self.array)): + min_idx = i + for j in range(i+1, len(self.array)): + if self.array[j] < self.array[min_idx]: + min_idx = j + self.array[i], self.array[min_idx] = self.array[min_idx], self.array[i] + self.update_display(self.array[i], self.array[min_idx]) + +# https://www.geeksforgeeks.org/insertion-sort/ +# Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. +class InsertionSort(Algorithm): + def __init__(self): + super().__init__("InsertionSort") + + def algorithm(self): + for i in range(len(self.array)): + cursor = self.array[i] + idx = i + while idx > 0 and self.array[idx-1] > cursor: + self.array[idx] = self.array[idx-1] + idx -= 1 + self.array[idx] = cursor + self.update_display(self.array[idx], self.array[i]) \ No newline at end of file diff --git a/sortingvisualizationtool.py b/sortingvisualizationtool.py new file mode 100644 index 0000000..cc79251 --- /dev/null +++ b/sortingvisualizationtool.py @@ -0,0 +1,20 @@ +# Sorting Algorithm Visualizer +# Inspired throughout my completion in our Data Structures and Algorithm's course during university + +# Beginning with sorting algorithms we learned first in-class which is inclusive of: +# Selection Sort +# Insertion Sort +# Quick Sort +# Merge Sort +# and more to come! + +# Visualization tool created using Python to complement the sorting algorithmic construction file: See current work in progress above + +#testing 123 + +import sortingalgorithm, time, os, sys + +os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" + +import pygame + From 1f8de0c7405a654cfc7a3606bd223372a3d83583 Mon Sep 17 00:00:00 2001 From: rickylai Date: Thu, 1 Apr 2021 23:23:30 -0700 Subject: [PATCH 03/10] Merge/Selection 1 --- README.md | 17 ++++- __pycache__/sortingalgorithm.cpython-39.pyc | Bin 0 -> 2108 bytes sortingalgorithm.py | 2 + sortingvisualizationtool.py | 69 +++++++++++++++++++- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 __pycache__/sortingalgorithm.cpython-39.pyc diff --git a/README.md b/README.md index 0ecb6ab..4f1c67b 100644 --- a/README.md +++ b/README.md @@ -1 +1,16 @@ -# DataStructuresAlgorithmsVisualization \ No newline at end of file +# DataStructuresAlgorithmsVisualization + +Inspired from my course in Data Structures & Algorithms + +Began brainstorming and implementing sorting algorithms utilized for class activities + +# Beginning with sorting algorithms we learned first in-class which is inclusive of: +# Selection Sort ( Worst Case: O(n^2), Best: Ω(n^2) ) +# Insertion Sort ( O(n^2), Ω(n) ) +# Quick Sort ( O(n^2), Ω(n log(n)) ) +# Merge Sort ( O(n log(n), Ω(n log(n)) ) +# and more to come! + +# Visualization tool created using Python to complement the sorting algorithmic construction file: See current work in progress above + +Includes comments for each sorting algorithm in "sortingalgorithm.py" noting the time complexity and description of each diff --git a/__pycache__/sortingalgorithm.cpython-39.pyc b/__pycache__/sortingalgorithm.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..186554e47425c7b5718a8ce566feca87196250d9 GIT binary patch literal 2108 zcmbVNOK&4Z5bno}Gd8g|gs^dz<^6P!BEbRBYK0ay5<)`0L|UOy&@h^wgvpM_PWPB4 zmMtN9rR8VDH~f3J&6U$0xpLyG9*-Y^1JG7izp87h>ieo4Hk%EG_Q$Vh-~U!;>~~tM zHwTLc=;liZ#S~AOUyj`8Uoj<=e9DxZ3SVI5C>JX?7E|dn*!>6hC1d?>X$S zZbWjuNh}_qoA)4M=5xh-p|}!HnJ<-REpy)~E&8sKuvIVWU!>=Ko#a3CB7u8Vqd7VL z5Z&B`$k{c|VQ$J5pNTOG2d!_mi9wsPLC25ho{G39-icS80AA9o28%TQDTN+ znvB9c>1U^=uk$23534Ya23Lg_1WA_UL9j>eQyh%%^3m?n#!;ovjVNtZBTX0GMtuhp zq>rU+BFFL?(IR3olN{jLm^Ft6qS;-z5d2s=W@25`h65GmamUeHP%2#WBpiHH4j=0m zuw}z81xUk+R(T;%i5aBfRU3N?$2~D>uN>c0i^zql5oXk__lKAOGd5#D3BF&88RN^H z3*KfE>|OxHGl6J$x8oE}p7i3PVe(Mtft}ZvY1NdMjwr*~ro$jk!-0v_%}AskX0Jlo z5U`9lxW`+3)Leytb1Q9UjwT-qnZ}u=l7+M? z51#m2y(9|~^;5ww)-bm4?&9Ky=%xihh3xP)-{Up@79Z_zCTB_4c}>3zWqq5(J_*Ys zGF3DeS&!m0tuk-PMDJY5C<5($bX$TR-n|i`qn-c& literal 0 HcmV?d00001 diff --git a/sortingalgorithm.py b/sortingalgorithm.py index 642015c..1c1552d 100644 --- a/sortingalgorithm.py +++ b/sortingalgorithm.py @@ -32,6 +32,8 @@ def run(self): time_elapsed = time.time() - self.start_time return self.array, time_elapsed +# Inspiration: https://www.youtube.com/watch?v=kFeXwkgnQ9U&ab_channel=DerrickSherrill + # https://www.geeksforgeeks.org/selection-sort/ # https://www.bigocheatsheet.com/ # https://en.wikipedia.org/wiki/Selection_sort diff --git a/sortingvisualizationtool.py b/sortingvisualizationtool.py index cc79251..bc36e57 100644 --- a/sortingvisualizationtool.py +++ b/sortingvisualizationtool.py @@ -13,8 +13,73 @@ #testing 123 import sortingalgorithm, time, os, sys - os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" - import pygame +# https://www.pygame.org/docs/tut/ImportInit.html +# https://docs.python.org/3/library/time.html +from pygame.locals import * + +# Inspiration: https://www.youtube.com/watch?v=kFeXwkgnQ9U&ab_channel=DerrickSherrill + +dimensions = (1200, 600) + +algorithms = {"SelectionSort": sorting_algorithms.SelectionSort(), \ + "InsertionSort": sorting_algorithms.InsertionSort()} + # will add Merge, Heap, and Quick Sort shortly +# https://www.geeksforgeeks.org/selection-sort/ +# https://www.geeksforgeeks.org/insertion-sort/ + +if len(sys.argv) > 1: + if sys.argv[1] == "list": + for key in algorithms.keys(): print(key, end=" ") + print("") + sys.exit(0) + +pygame.init() +display = pygame.display.set_mode((dimensions[0], dimensions[1])) +display.fill(pygame.Color("white")) + + +def check_events(): + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit(); + +def update(algorithm, swap1=None, swap2=None, display=display): + display.fill(pygame.Color("white")) + pygame.display.set_caption("Sorting Visualiser Algorithm: {} Time: {:.3f} Status: Sorting".format(algorithm.name, time.time() - algorithm.start_time)) + k = int(dimensions[0]/len(algorithm.array)) + for i in range(len(algorithm.array)): + colour = (0,0,0) + if swap1 == algorithm.array[i]: + colour = (0,255,0) + elif swap2 == algorithm.array[i]: + colour = (255,0,0) + pygame.draw.rect(display, colour, (i*k,dimensions[1],k,-algorithm.array[i])) + check_events() + pygame.display.update() + +def keep_open(algorithm, display, time): + pygame.display.set_caption("Sorting Visualiser Algorithm: {} Time: {:.3f} Status: Done".format(algorithm.name, time)) + while True: + check_events() + pygame.display.update() + +def main(): + if len(sys.argv) < 2: + print("Error: Enter a sorting algorithm") + else: + try: + algorithm = algorithms[sys.argv[1]] + try: + time_elapsed = algorithm.run()[1] + keep_open(algorithm, display, time_elapsed) + pass + except: + pass + except: + print("Error: {} is not a valid sorting algorithm".format(sys.argv[1])) + print("Note: Sorting algorithms are in Camel Case") +if __name__ == "__main__": + main() \ No newline at end of file From 9acf5782912a51ca738ec4b09ac4a21feb864595 Mon Sep 17 00:00:00 2001 From: rickylai Date: Thu, 1 Apr 2021 23:24:31 -0700 Subject: [PATCH 04/10] Testing 1 From ebba6f4c6f2de1a499865c2597b23671c611da5f Mon Sep 17 00:00:00 2001 From: rickylai Date: Sun, 4 Apr 2021 22:59:44 -0700 Subject: [PATCH 05/10] Added comments --- sortingalgorithm.py | 7 ++++--- sortingvisualizationtool.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sortingalgorithm.py b/sortingalgorithm.py index 1c1552d..693a183 100644 --- a/sortingalgorithm.py +++ b/sortingalgorithm.py @@ -21,7 +21,7 @@ def __init__(self, name): self.array = random.sample(range(512), 512) self.name = name - def update_display(self, swap1=None, swap2=None): + def refreshScreen(self, swap1=None, swap2=None): import sorting_visualiser sorting_visualiser.update(self, swap1, swap2) @@ -49,7 +49,7 @@ def algorithm(self): if self.array[j] < self.array[min_idx]: min_idx = j self.array[i], self.array[min_idx] = self.array[min_idx], self.array[i] - self.update_display(self.array[i], self.array[min_idx]) + self.refreshScreen(self.array[i], self.array[min_idx]) # https://www.geeksforgeeks.org/insertion-sort/ # Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. @@ -61,8 +61,9 @@ def algorithm(self): for i in range(len(self.array)): cursor = self.array[i] idx = i + # set idx equal to i index while idx > 0 and self.array[idx-1] > cursor: self.array[idx] = self.array[idx-1] idx -= 1 self.array[idx] = cursor - self.update_display(self.array[idx], self.array[i]) \ No newline at end of file + self.refreshScreen(self.array[idx], self.array[i]) \ No newline at end of file diff --git a/sortingvisualizationtool.py b/sortingvisualizationtool.py index bc36e57..ae94404 100644 --- a/sortingvisualizationtool.py +++ b/sortingvisualizationtool.py @@ -40,12 +40,12 @@ display.fill(pygame.Color("white")) -def check_events(): +def checkIfQuit(): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit(); sys.exit(); -def update(algorithm, swap1=None, swap2=None, display=display): +def refresh(algorithm, swap1=None, swap2=None, display=display): display.fill(pygame.Color("white")) pygame.display.set_caption("Sorting Visualiser Algorithm: {} Time: {:.3f} Status: Sorting".format(algorithm.name, time.time() - algorithm.start_time)) k = int(dimensions[0]/len(algorithm.array)) @@ -56,14 +56,14 @@ def update(algorithm, swap1=None, swap2=None, display=display): elif swap2 == algorithm.array[i]: colour = (255,0,0) pygame.draw.rect(display, colour, (i*k,dimensions[1],k,-algorithm.array[i])) - check_events() - pygame.display.update() + checkIfQuit() + pygame.display.refresh() -def keep_open(algorithm, display, time): +def whileActive(algorithm, display, time): pygame.display.set_caption("Sorting Visualiser Algorithm: {} Time: {:.3f} Status: Done".format(algorithm.name, time)) while True: - check_events() - pygame.display.update() + checkIfQuit() + pygame.display.refresh() def main(): if len(sys.argv) < 2: @@ -73,11 +73,12 @@ def main(): algorithm = algorithms[sys.argv[1]] try: time_elapsed = algorithm.run()[1] - keep_open(algorithm, display, time_elapsed) + whileActive(algorithm, display, time_elapsed) pass except: pass except: + # catch excepts print("Error: {} is not a valid sorting algorithm".format(sys.argv[1])) print("Note: Sorting algorithms are in Camel Case") From 17cc0bd418fbe8026108a49f804d8f1c87d2a266 Mon Sep 17 00:00:00 2001 From: rickylai Date: Sun, 4 Apr 2021 22:59:52 -0700 Subject: [PATCH 06/10] Testing 1 --- __pycache__/sortingalgorithm.cpython-39.pyc | Bin 2108 -> 2106 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/__pycache__/sortingalgorithm.cpython-39.pyc b/__pycache__/sortingalgorithm.cpython-39.pyc index 186554e47425c7b5718a8ce566feca87196250d9..62cddfa2e1d18565794056019bb70159f1d6a20f 100644 GIT binary patch delta 642 zcmZvY&q~8U5XQSn)1c;tP28mV;*>!tDUS_mKnh>cy3>unJ-D5u|T9)!O$@| zia=Z(v(KtQ4$Z%=^>@Nw2@;rs_^(itzyf{=+;5fZz-)ShJwaG%IXi<+ut^q4CIE70ihK2OH-jf51wn^> z4nP$nCVP)q5OKsapvk8EPo?@G-(=2RQ(YR9l3#TTYbm0-N5&(n=;e_2_!*O;kLZvo%N{O zKkuynwy`_mvMz(GAy6Ka>AM}rbUe!s9D6#0rNx69;?g`y5oLnFR~ow)hb>GF1wbA6 z4yD);5v zITYRy9~ie7vB@5jZ+lhT) Date: Sat, 10 Apr 2021 23:06:00 -0700 Subject: [PATCH 07/10] Updated comments for algorithms --- sortingalgorithm.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/sortingalgorithm.py b/sortingalgorithm.py index 693a183..271488e 100644 --- a/sortingalgorithm.py +++ b/sortingalgorithm.py @@ -8,25 +8,25 @@ # Merge Sort # and more to come! -#import sorting_algorithms, time, os, sys -#os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" -#import pygame - -#testing 123 +# OOP based implementation import random, time class Algorithm: def __init__(self, name): + # constructor self.array = random.sample(range(512), 512) + # Builtin Python function + # returns a particular length list of items chosen from the sequence i.e. list, tuple, string or set. Used for random sampling without replacement. self.name = name def refreshScreen(self, swap1=None, swap2=None): import sorting_visualiser - sorting_visualiser.update(self, swap1, swap2) + # The update() method updates the dictionary with the elements from the another dictionary object or from an iterable of key/value pairs. def run(self): + # runs the algorithm self.start_time = time.time() self.algorithm() time_elapsed = time.time() - self.start_time @@ -37,33 +37,42 @@ def run(self): # https://www.geeksforgeeks.org/selection-sort/ # https://www.bigocheatsheet.com/ # https://en.wikipedia.org/wiki/Selection_sort -# The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array. +# "The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array. class SelectionSort(Algorithm): def __init__(self): super().__init__("SelectionSort") def algorithm(self): + # traverse through all the elments in array for i in range(len(self.array)): + # "Find the minimum element in remaining unsorted array" min_idx = i for j in range(i+1, len(self.array)): if self.array[j] < self.array[min_idx]: min_idx = j + # "Swap the found minimum element with the first element "" self.array[i], self.array[min_idx] = self.array[min_idx], self.array[i] + # update screen self.refreshScreen(self.array[i], self.array[min_idx]) # https://www.geeksforgeeks.org/insertion-sort/ -# Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. +# "Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. class InsertionSort(Algorithm): def __init__(self): super().__init__("InsertionSort") def algorithm(self): + # traverse entire length of array for i in range(len(self.array)): cursor = self.array[i] + # "Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current position" idx = i # set idx equal to i index while idx > 0 and self.array[idx-1] > cursor: self.array[idx] = self.array[idx-1] idx -= 1 self.array[idx] = cursor + # represents the key in this case + + # refresh screen self.refreshScreen(self.array[idx], self.array[i]) \ No newline at end of file From 03d94279f11d9ebcb005eb4456baf05be47438a7 Mon Sep 17 00:00:00 2001 From: rickylai Date: Sat, 10 Apr 2021 23:16:54 -0700 Subject: [PATCH 08/10] Comments visualization, changed exception handling --- sortingvisualizationtool.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/sortingvisualizationtool.py b/sortingvisualizationtool.py index ae94404..9ec7feb 100644 --- a/sortingvisualizationtool.py +++ b/sortingvisualizationtool.py @@ -9,46 +9,58 @@ # and more to come! # Visualization tool created using Python to complement the sorting algorithmic construction file: See current work in progress above - -#testing 123 +# Primarily for reference import sortingalgorithm, time, os, sys +# https://docs.python.org/3/library/time.html +# https://www.geeksforgeeks.org/os-module-python-examples/ (important) +# https://www.python-course.eu/sys_module.php os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" +# captures mapping, represents string environment import pygame +# https://www.pygame.org/docs/ (custom effects, etc.) # https://www.pygame.org/docs/tut/ImportInit.html # https://docs.python.org/3/library/time.html from pygame.locals import * +# imports the pygame module into the "pygame" namespace (saves typing) # Inspiration: https://www.youtube.com/watch?v=kFeXwkgnQ9U&ab_channel=DerrickSherrill dimensions = (1200, 600) +# able to change width, height +# warning: y value should fit array len algorithms = {"SelectionSort": sorting_algorithms.SelectionSort(), \ "InsertionSort": sorting_algorithms.InsertionSort()} - # will add Merge, Heap, and Quick Sort shortly + # will add Merge, Heap, and Quick Sort in the near future # https://www.geeksforgeeks.org/selection-sort/ # https://www.geeksforgeeks.org/insertion-sort/ if len(sys.argv) > 1: if sys.argv[1] == "list": for key in algorithms.keys(): print(key, end=" ") + # returns a view object print("") sys.exit(0) pygame.init() +# safely initalizes all imported pygame modules display = pygame.display.set_mode((dimensions[0], dimensions[1])) +# https://www.pygame.org/docs/ref/display.html display.fill(pygame.Color("white")) - def checkIfQuit(): + # check for quit event for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit(); sys.exit(); def refresh(algorithm, swap1=None, swap2=None, display=display): display.fill(pygame.Color("white")) - pygame.display.set_caption("Sorting Visualiser Algorithm: {} Time: {:.3f} Status: Sorting".format(algorithm.name, time.time() - algorithm.start_time)) + + pygame.display.set_caption("Sorting Visualization Tool Algorithm: {} Time: {:.3f} Status: Sorting".format(algorithm.name, time.time() - algorithm.start_time)) k = int(dimensions[0]/len(algorithm.array)) + for i in range(len(algorithm.array)): colour = (0,0,0) if swap1 == algorithm.array[i]: @@ -56,18 +68,20 @@ def refresh(algorithm, swap1=None, swap2=None, display=display): elif swap2 == algorithm.array[i]: colour = (255,0,0) pygame.draw.rect(display, colour, (i*k,dimensions[1],k,-algorithm.array[i])) + checkIfQuit() pygame.display.refresh() def whileActive(algorithm, display, time): - pygame.display.set_caption("Sorting Visualiser Algorithm: {} Time: {:.3f} Status: Done".format(algorithm.name, time)) + pygame.display.set_caption("Sorting Visualization Tool Algorithm: {} Time: {:.3f} Status: Done".format(algorithm.name, time)) + while True: checkIfQuit() pygame.display.refresh() def main(): if len(sys.argv) < 2: - print("Error: Enter a sorting algorithm") + print("Exception: Please enter a sorting algorithm") else: try: algorithm = algorithms[sys.argv[1]] @@ -79,8 +93,8 @@ def main(): pass except: # catch excepts - print("Error: {} is not a valid sorting algorithm".format(sys.argv[1])) - print("Note: Sorting algorithms are in Camel Case") + print("Exception: {} is not one of the valid sorting algorithms".format(sys.argv[1])) + print("Side Note: Sorting algorithms are in Camel Case format") if __name__ == "__main__": main() \ No newline at end of file From 114d9be6f275648c03c7fca06ae510a1ce17e823 Mon Sep 17 00:00:00 2001 From: rickylai Date: Sun, 11 Apr 2021 01:01:21 -0700 Subject: [PATCH 09/10] Updated descriptions of algorithms --- README.md | 4 ++-- sortingalgorithm.py | 1 - sortingvisualizationtool.py | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f1c67b..1b6d755 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # DataStructuresAlgorithmsVisualization -Inspired from my course in Data Structures & Algorithms +Inspired from my course in Data Structures & Algorithms (i.e. sorting, graphs, heap) -Began brainstorming and implementing sorting algorithms utilized for class activities +Began brainstorming and implementing sorting algorithms utilized for class activities (Documentation also included) # Beginning with sorting algorithms we learned first in-class which is inclusive of: # Selection Sort ( Worst Case: O(n^2), Best: Ω(n^2) ) diff --git a/sortingalgorithm.py b/sortingalgorithm.py index 271488e..0d6c2b6 100644 --- a/sortingalgorithm.py +++ b/sortingalgorithm.py @@ -33,7 +33,6 @@ def run(self): return self.array, time_elapsed # Inspiration: https://www.youtube.com/watch?v=kFeXwkgnQ9U&ab_channel=DerrickSherrill - # https://www.geeksforgeeks.org/selection-sort/ # https://www.bigocheatsheet.com/ # https://en.wikipedia.org/wiki/Selection_sort diff --git a/sortingvisualizationtool.py b/sortingvisualizationtool.py index 9ec7feb..e74a987 100644 --- a/sortingvisualizationtool.py +++ b/sortingvisualizationtool.py @@ -21,6 +21,7 @@ # https://www.pygame.org/docs/ (custom effects, etc.) # https://www.pygame.org/docs/tut/ImportInit.html # https://docs.python.org/3/library/time.html + from pygame.locals import * # imports the pygame module into the "pygame" namespace (saves typing) From ea4f0f93f8bb920cfde1012be81c5ab8d60a54e7 Mon Sep 17 00:00:00 2001 From: rickylai Date: Sun, 11 Apr 2021 01:05:34 -0700 Subject: [PATCH 10/10] Added instructions in-progress --- README.md | 2 ++ __pycache__/sortingalgorithm.cpython-39.pyc | Bin 2106 -> 2106 bytes 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 1b6d755..2d01d13 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,5 @@ Began brainstorming and implementing sorting algorithms utilized for class activ # Visualization tool created using Python to complement the sorting algorithmic construction file: See current work in progress above Includes comments for each sorting algorithm in "sortingalgorithm.py" noting the time complexity and description of each + +Runnable i.e. open sortingvisualizationtool in terminal then specify algorithm diff --git a/__pycache__/sortingalgorithm.cpython-39.pyc b/__pycache__/sortingalgorithm.cpython-39.pyc index 62cddfa2e1d18565794056019bb70159f1d6a20f..b404a8d7014801e670fc6141d32ce8af1fed1c7a 100644 GIT binary patch delta 753 zcmZuv!A{#i5Y4RZ#H83*Kq0gU1hi5kAtVs0kU(vPdH|_Xk$_7s#w6R~%CV!_1Q0#+ z(nAkiV80@$mtIkSfHOCL03Xp)XEtex5SI3NJ^N{P<&r=C{h(@stvc}rVM2gwUlf;EM#FPo#u3wRS(knJyR&UC4*Ru%1Lph2gyoL#gUL z`*x3qkXwmNk)@mNRlBDj;##R0r(xVU&Ed;KC8I=Nq@{cU8l$kG0^?8=^Fn`hrawNV zC{8f&luSqDoZRaRs>>w#C(2mmaiDR@eqPZsvvpzE!iv6gek{CX#uUSI29sb?O&0s! z&=&4OVGE1bF{A&>m5`X)+{pgn47mmQv7F-8z>7~JR?74DBEX~+o_V+jzsv!@Q`EMzAH=0?algKw7 N(afC(!k-Gp{sJAOfr0=4 delta 753 zcmZuu%TC)+5Y70Jm=L?>6&|7#0YXZpB7smvC4?$gMMA17=!T7PlUp!y>}YNR2o`Ku zu;`|}-@qc>vE>iC?(Tj-KY~?fZbFGrZOysk@jT9%dmrA1LG1hG0zLZn|Q;E6?KAYVTOX3WZEn54gGZQG7)q zkN4^*L^egCejCqHU##nmB1LKznr@YL(iD+MrK;$-EFdVv|hoY#S#!^PnlMIvcTJ1Z( z_gzZXb}BODj%Iqz>G6l;pwvvVC~2H)IC;*5S-c^W0RgYkfhib=A}oNqbZ0+SDT~Yr@j|| zUA^MJ^8|erXW+@AbXO)k(!G(my9s*T_Q_0$pdZvNz&eCGjDWKvBd@E&O