File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ const ACTIONS = {
3636 "CONTINUE" : "Right" ,
3737}
3838var _index = 0 # First of two elements being compared
39- var _sorted = 0 # Size of the sorted subarray at the end of the array
39+ var _sorted = 0 # Size of the sorted subarrays at the two ends of the array
4040var _forwards = true
4141var _swapped = false
4242
@@ -61,6 +61,8 @@ func next(action):
6161 _forwards = false
6262 _index -= 2
6363 _sorted += 1
64+ if _sorted == array .size / 2 :
65+ emit_signal ("done" )
6466 else :
6567 _index -= 1
6668 if _index == _sorted - 2 :
Original file line number Diff line number Diff line change 11class_name MergeSort
22extends ComparisonSort
33
4+ # BUG: Crashes on array sizes that are not powers of two
5+
46const NAME = "MERGE SORT"
57const DESCRIPTION = """
68Merge sort merges subarrays of increasing size by setting a pointer to
You can’t perform that action at this time.
0 commit comments