33
44import { msort_arr_bup } from '../explanations' ;
55import ArrayTracer from '../../components/DataStructures/Array/Array1DTracer' ;
6+ import { colors } from '../../components/DataStructures/colors' ;
67
78
89import {
@@ -23,11 +24,11 @@ import {
2324
2425const run = run_msort ( ) ;
2526
26- const apColor = "green" ; // replace with red
27- const runAColor = "red" ; // replace with orange
28- const runBColor = "green" ; // replace with blue
29- const runCColor = "red" ; // replace all instances of runCColor with runBColor
30- const sortColor = "green" ;
27+ const apColor = colors . apple ;
28+ const runAColor = colors . peach ;
29+ const runBColor = colors . sky ;
30+ const runCColor = colors . sky ; // replace all instances of runCColor with runBColor
31+ const sortColor = colors . leaf ;
3132
3233
3334export default {
@@ -174,6 +175,7 @@ export function run_msort() {
174175 if ( isMergeExpanded ( ) ) {
175176 assignVarToA ( vis , 'left' , undefined , size ) ; // ap1 replaces left
176177 assignVarToA ( vis , 'ap1' , c_ap1 , size ) ;
178+ highlight ( vis , c_ap1 , apColor ) ;
177179 assignVarToA ( vis , 'mid' , c_mid , size ) ;
178180 assignVarToA ( vis , 'right' , c_right , size ) ;
179181 }
@@ -187,6 +189,7 @@ export function run_msort() {
187189 chunker . add ( 'ap2' , ( vis , c_ap2 ) => {
188190 if ( isMergeExpanded ( ) ) {
189191 assignVarToA ( vis , 'ap2' , c_ap2 , size ) ;
192+ highlight ( vis , c_ap2 , apColor ) ;
190193 }
191194 } , [ ap2 ] ) ;
192195 chunker . add ( 'max2' , ( vis , c_max2 , c ) => {
@@ -204,16 +207,15 @@ export function run_msort() {
204207 // while (ap1 <= max1 && ap2 <= max2)
205208 /* eslint-disable no-constant-condition */
206209 while ( true ) {
207- if ( ! ( ap1 <= max1 && ap2 <= max2 ) ) break ;
208-
209210 chunker . add ( 'MergeWhile' , ( vis , c_ap1 , c_max1 , c_ap2 , c_max2 ) => {
210211 highlightAPointers ( vis , c_ap1 , c_max1 , c_ap2 , c_max2 , apColor ) ;
211212 } , [ ap1 , max1 , ap2 , max2 ] ) ;
213+ if ( ! ( ap1 <= max1 && ap2 <= max2 ) ) break ;
212214
215+ chunker . add ( 'findSmaller' , ( ) => {
216+ // no animation
217+ } , [ ] ) ;
213218 if ( A [ ap1 ] < A [ ap2 ] ) {
214- chunker . add ( 'findSmaller' , ( ) => {
215- // no animation
216- } , [ ] ) ;
217219 B [ bp ] = A [ ap1 ] ;
218220 A [ ap1 ] = undefined ;
219221 chunker . add ( 'copyap1' , ( vis , a , b , c_ap1 , c_max1 , c_ap2 , c_max2 , c_bp , c_left , c_right , c_mid , c_rlength ) => {
@@ -238,9 +240,9 @@ export function run_msort() {
238240 }
239241
240242 else {
241- chunker . add ( 'findSmallerB' , ( ) => {
243+ // chunker.add('findSmallerB', () => {
242244 // no animation
243- } , [ ] ) ;
245+ // }, []);
244246 B [ bp ] = A [ ap2 ] ;
245247 A [ ap2 ] = undefined ;
246248 chunker . add ( 'copyap2' , ( vis , a , b , c_ap1 , c_ap2 , c_bp , c_max1 , c_max2 , c_left , c_right , c_mid , c_rlength ) => {
0 commit comments