Skip to content

Commit abbc54d

Browse files
committed
2 parents 39434c9 + c33a317 commit abbc54d

File tree

16 files changed

+169
-59
lines changed

16 files changed

+169
-59
lines changed

AlgoVisual.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def main(fps):
1717
midi = Wrapper.Midi()
1818

1919
screen_group = pygame.sprite.Group()
20+
options_real_group = pygame.sprite.Group()
2021
options_screen_group = pygame.sprite.Group()
2122
sorting_group = pygame.sprite.Group()
2223
aux_sorting_group = pygame.sprite.Group()
@@ -27,7 +28,7 @@ def main(fps):
2728
scroll_bar = []
2829
sorting_actions = None
2930

30-
UI.MainMenuActions.display_main_menu(window, True, screen_group, options_screen_group)
31+
UI.MainMenuActions.display_main_menu(window, True, screen_group, options_screen_group, midi)
3132

3233
while True:
3334
# General Events should be placed here
@@ -46,10 +47,10 @@ def main(fps):
4647
# apparentally python has no switch cases?
4748
# This should only have logic for what to do when its on screen x or something like that
4849
if (window.screen == Wrapper.Screen.MAIN_MENU and window.window_size_change):
49-
UI.MainMenuActions.display_main_menu(window, False, screen_group, options_screen_group)
50+
options_real_group = UI.MainMenuActions.display_main_menu(window, False, screen_group, options_screen_group, midi)
5051
window.window_size_change = False
5152
elif (window.screen == Wrapper.Screen.MAIN_MENU and window.screen_change):
52-
UI.MainMenuActions.display_main_menu(window, True, screen_group, options_screen_group)
53+
options_real_group = UI.MainMenuActions.display_main_menu(window, True, screen_group, options_screen_group, midi)
5354
window.screen_change = False
5455
elif (window.screen == Wrapper.Screen.SORTING_SCREEN and window.screen_change):
5556
sorting_actions = UI.SortingActions(window, screen_group, sorting_group, aux_sorting_group, [scroll_group_1, scroll_group_2], options_screen_group, text_box_group, midi)
@@ -101,6 +102,7 @@ def main(fps):
101102
options_screen_group.update()
102103
text_box_group.draw(window.window)
103104
text_box_group.update(events_list)
105+
options_real_group.update()
104106

105107
# Must have to update
106108
pygame.display.update()

Algorithms/Sorting.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ def quick_sort_method(arr, event, begin, end):
5858
arr.swap(i, low)
5959
low += 1
6060
if (event.is_set()):
61-
return
61+
return -1
6262

6363
arr.swap(low, pivot)
64-
quick_sort_method(arr, event, begin, low)
65-
quick_sort_method(arr, event, low+1, end)
64+
if (quick_sort_method(arr, event, begin, low) == -1):
65+
return -1
66+
if (quick_sort_method(arr, event, low+1, end) == -1):
67+
return -1
6668

6769
''' Merge Sort - O(nlogn)
6870
The array will be split into two even parts (not exactly even if the array has an odd number of elements)
@@ -79,8 +81,10 @@ def merge_sort(arr, event, aux = None):
7981
def merge_sort_method(arr, event, begin, end):
8082
if (begin+1 < end):
8183
mid = begin + ((end-begin)+1)//2
82-
merge_sort_method(arr, event, begin, mid)
83-
merge_sort_method(arr, event, mid, end)
84+
if (merge_sort_method(arr, event, begin, mid) == -1):
85+
return -1
86+
if (merge_sort_method(arr, event, mid, end) == -1):
87+
return -1
8488
arrL = arr.list[begin:mid]
8589
arrR = arr.list[mid:end]
8690
i = j = 0
@@ -93,21 +97,21 @@ def merge_sort_method(arr, event, begin, end):
9397
arr.replace(k, arrR[j])
9498
j += 1
9599
if (event.is_set()):
96-
return
100+
return -1
97101
k += 1
98102

99103
while i < len(arrL):
100104
arr.replace(k, arrL[i])
101105
i += 1
102106
k += 1
103107
if (event.is_set()):
104-
return
108+
return -1
105109
while j < len(arrR):
106110
arr.replace(k, arrR[j])
107111
j += 1
108112
k += 1
109113
if (event.is_set()):
110-
return
114+
return -1
111115

112116
''' Heap Sort (nlogn) - Also the implementation of the Priority Queue using the Heap Data Structure
113117
All elements of the array will be inserted into what is known as a "Heap".
File renamed without changes.
File renamed without changes.

Images/Volume/volume_low.png

9.47 KB
Loading

Images/Volume/volume_max.png

5.8 KB
Loading

Images/Volume/volume_medium.png

14.9 KB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)