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 = {
36
36
"CONTINUE" : "Right" ,
37
37
}
38
38
var _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
40
40
var _forwards = true
41
41
var _swapped = false
42
42
@@ -61,6 +61,8 @@ func next(action):
61
61
_forwards = false
62
62
_index -= 2
63
63
_sorted += 1
64
+ if _sorted == array .size / 2 :
65
+ emit_signal ("done" )
64
66
else :
65
67
_index -= 1
66
68
if _index == _sorted - 2 :
Original file line number Diff line number Diff line change 1
1
class_name MergeSort
2
2
extends ComparisonSort
3
3
4
+ # BUG: Crashes on array sizes that are not powers of two
5
+
4
6
const NAME = "MERGE SORT"
5
7
const DESCRIPTION = """
6
8
Merge sort merges subarrays of increasing size by setting a pointer to
You can’t perform that action at this time.
0 commit comments