From 12181be3042013d4786c6d0652db58db1f324e42 Mon Sep 17 00:00:00 2001 From: William E Bodell III Date: Wed, 3 Mar 2021 15:10:26 -0600 Subject: [PATCH 1/2] Fix counts array visualization in Counting Sort Final step did not correctly visualize decrementing the value in the counts array. It was decrementing the value but not updating the visualization. --- Divide and Conquer/Counting Sort/code.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Divide and Conquer/Counting Sort/code.js b/Divide and Conquer/Counting Sort/code.js index aea80f8f..e1281263 100644 --- a/Divide and Conquer/Counting Sort/code.js +++ b/Divide and Conquer/Counting Sort/code.js @@ -58,15 +58,16 @@ const array = Randomize.Array1D({ N, value: () => Randomize.Integer({ min: 0, ma const number = array[i]; const count = counts[number]; sortedArray[count - 1] = number; + counts[number]--; // visualize { arrayTracer.select(i); countsTracer.select(number); sortedArrayTracer.patch(count - 1, sortedArray[count - 1]); + countsTracer.patch(number, counts[number]); Tracer.delay(); sortedArrayTracer.depatch(count - 1); countsTracer.deselect(number); arrayTracer.deselect(i); // } - counts[number]--; } })(); From 579eb0bec5e3f8c9930de8421794a54cf5125c51 Mon Sep 17 00:00:00 2001 From: William E Bodell III Date: Wed, 3 Mar 2021 15:25:38 -0600 Subject: [PATCH 2/2] Add countsTracer.depatch My previously committed code left the boxes in the counts array colored red, so I realized I had forgotten to add a depatch after the patch that I added at line 66 --- Divide and Conquer/Counting Sort/code.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Divide and Conquer/Counting Sort/code.js b/Divide and Conquer/Counting Sort/code.js index e1281263..4293fade 100644 --- a/Divide and Conquer/Counting Sort/code.js +++ b/Divide and Conquer/Counting Sort/code.js @@ -66,6 +66,7 @@ const array = Randomize.Array1D({ N, value: () => Randomize.Integer({ min: 0, ma countsTracer.patch(number, counts[number]); Tracer.delay(); sortedArrayTracer.depatch(count - 1); + countsTracer.depatch(number); countsTracer.deselect(number); arrayTracer.deselect(i); // } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy