Skip to content

Commit 33d87bf

Browse files
committed
REX sort stack only with recursion expanded
1 parent aa9b077 commit 33d87bf

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/algorithms/controllers/MSDRadixSort.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Some color code could be cleaned up
22
// Could share some code with straight radix sort and quicksort
3+
// Best make stack as similar as possible; also add to mergesort ideally
34
import ArrayTracer from '../../components/DataStructures/Array/Array1DTracer';
45
import MaskTracer from '../../components/DataStructures/Mask/MaskTracer'
56
import {
@@ -241,10 +242,13 @@ export default {
241242
}
242243
}
243244

244-
vis.array.setStackDepth(cur_real_stack.length);
245-
vis.array.setStack(
246-
deriveStack(cur_real_stack, cur_finished_stack_frames, cur_i, cur_j, cur_depth)
247-
);
245+
if (isRecursionExpanded()) {
246+
vis.array.setStackDepth(cur_real_stack.length);
247+
vis.array.setStack(
248+
deriveStack(cur_real_stack, cur_finished_stack_frames, cur_i, cur_j, cur_depth)
249+
);
250+
} else
251+
vis.array.setStack([]);
248252
if (left < A.length) // shouldn't happen with initial mask choice
249253
assignVariable(vis, VIS_VARIABLE_STRINGS.left, left);
250254
if (right >= 0) {
@@ -563,7 +567,10 @@ arr],
563567
vis.array.sorted(k);
564568
}
565569
vis.array.clearVariables();
566-
vis.array.setStack(deriveStack(real_stack, finished_stack_frames));
570+
if (isRecursionExpanded()) {
571+
vis.array.setStack(deriveStack(real_stack, finished_stack_frames));
572+
} else
573+
vis.array.setStack([]);
567574
}, [],
568575
0
569576
);

src/algorithms/controllers/collapseChunkPlugin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// that (eg show less/more information). There was an accumulation
33
// of different versions of this for different algorithms. This is a
44
// more generic one that requires some extra some code in algorithm files.
5+
// There is still another one for transitiveClosure
56
// Possibly should be put elsewhere, eg, src/context/
67
// NOTE: any algorithm controller file that imports this must be listed
78
// below, otherwise hooks into what happens when blocks are expanded or
89
// contracted are not enabled.
910
const importsThis = ['quickSort', 'quickSortM3', 'msort_arr_td',
10-
'transitiveClosure', 'heapSort', 'msort_lista_td', 'msort_arr_bup',
11-
'msort_arr_nat', 'radixSortStraight'];
11+
'heapSort', 'msort_lista_td', 'msort_arr_bup',
12+
'msort_arr_nat', 'radixSortStraight', 'radixSortMSD'];
1213

1314
// eslint-disable-next-line import/no-cycle
1415
// See also accompanying mods/hooks in src/context/GlobalState.js and

0 commit comments

Comments
 (0)