|
1 | 1 | // Some color code could be cleaned up |
2 | 2 | // Could share some code with straight radix sort and quicksort |
| 3 | +// Best make stack as similar as possible; also add to mergesort ideally |
3 | 4 | import ArrayTracer from '../../components/DataStructures/Array/Array1DTracer'; |
4 | 5 | import MaskTracer from '../../components/DataStructures/Mask/MaskTracer' |
5 | 6 | import { |
@@ -241,10 +242,13 @@ export default { |
241 | 242 | } |
242 | 243 | } |
243 | 244 |
|
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([]); |
248 | 252 | if (left < A.length) // shouldn't happen with initial mask choice |
249 | 253 | assignVariable(vis, VIS_VARIABLE_STRINGS.left, left); |
250 | 254 | if (right >= 0) { |
@@ -563,7 +567,10 @@ arr], |
563 | 567 | vis.array.sorted(k); |
564 | 568 | } |
565 | 569 | 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([]); |
567 | 574 | }, [], |
568 | 575 | 0 |
569 | 576 | ); |
|
0 commit comments