Skip to content

Commit

Permalink
fixed some radix sort colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ZouheirN committed Feb 12, 2023
1 parent fb716b0 commit 0586297
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Assets/Scripts/ArrayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,18 +703,20 @@ IEnumerator CountingSort(int[] Array, int place) {
//count number of occurrences in freq array
for (int i = 0; i < n; i++) {
yield return new WaitForSeconds(time);
pillars[i].GetComponent<Pillar>().Color = tempColor;
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
pillars[i].GetComponent<Pillar>().Color = swapColor;
freq[(Array[i] / place) % 10]++;
}

for (int i = 0; i < Array.Length; i++) {
pillars[i].GetComponent<Pillar>().Color = whiteColor;
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
pillars[i].GetComponent<Pillar>().Color = whiteColor;
}

//Change count[i] so that count[i] now contains actual
//position of this digit in output[]
for (int i = 1; i < 10; i++) {
yield return new WaitForSeconds(time);
//yield return new WaitForSeconds(time);
freq[i] += freq[i - 1];
}

Expand All @@ -723,11 +725,13 @@ IEnumerator CountingSort(int[] Array, int place) {
yield return new WaitForSeconds(time);
output[freq[(Array[i] / place) % 10] - 1] = Array[i];
freq[(Array[i] / place) % 10]--;
pillars[i].GetComponent<Pillar>().Color = tempColor;
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
pillars[i].GetComponent<Pillar>().Color = tempColor;
}

for (int i = 0; i < Array.Length; i++) {
pillars[i].GetComponent<Pillar>().Color = whiteColor;
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
pillars[i].GetComponent<Pillar>().Color = whiteColor;
}

//Copy the output array to the input Array, Now the Array will
Expand Down
Binary file modified docs/Build/docs.data
Binary file not shown.
Binary file modified docs/Build/docs.wasm
Binary file not shown.

0 comments on commit 0586297

Please sign in to comment.