Skip to content

Commit e3a6200

Browse files
committed
Radix sort
1 parent 93860fc commit e3a6200

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/components/Canvas/InputField.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class InputField extends Component {
6565
this.Strategy.setStrategy = this.radixSortLSD;
6666
this.setState({algorithm: 'Radix'});
6767
}}
68-
className={`cursor-pointer hover:scale-[1.05] transition-all duration-200 ease-in-out border-2 hover:bg-blue-200 hover:border-blue-300 ${algorithm === 'Bubble' ? "bg-blue-100 border-blue-300" : "border-gray-300 bg-white"} min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center`}>
68+
className={`cursor-pointer hover:scale-[1.05] transition-all duration-200 ease-in-out border-2 hover:bg-blue-200 hover:border-blue-300 ${algorithm === 'Radix' ? "bg-blue-100 border-blue-300" : "border-gray-300 bg-white"} min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center`}>
6969
<p className="font-semibold">Radix Sort</p>
7070
</div>
7171

‎src/components/Strategy/Algorithms/RadixSortLSD.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class RadixSortLSD {
4343
}
4444

4545

46+
// TODO need to add colors to bars being processed
4647
for (i = k - 1; i >= 0; i--) {
4748
await Animation.getAnimation(DELAY);
4849
const oldValue = array[i]; // value being sorted to a new index
@@ -55,11 +56,15 @@ class RadixSortLSD {
5556
DOM[oldIndex].style.backgroundColor = SORTED_COLOR;
5657
DOM[sortedIndex].style.backgroundColor = SORTED_COLOR;
5758
}
59+
// BUG empty elements in bucket are ccurrently olored green due to
60+
// TODO make sure that empty elemets in bucket are the default color
61+
// TODO grab those elements from DOM and change color back to defaut OR add a new condition in above if(finalIteration)
5862

5963
sortedArray[sortedIndex] = oldValue;
6064
bucket[Math.floor(array[i] / exp) % 100]--;
6165
}
6266

67+
6368
for (i = 0; i < k; i++) { // SG 07/10/2022 22:35 copying sorted values
6469
array[i] = sortedArray[i];
6570
}

0 commit comments

Comments
 (0)