Difference between revisions of "TADM2E 4.4"
From Algorithm Wiki
(Recovering wiki) |
m (add stable sort) |
||
| Line 1: | Line 1: | ||
| − | Algorithm: | + | Any stable sort can solve this problem, using the color as the key: |
| + | such as insertion sort, merge sort or bucket sort(below) | ||
| + | |||
| + | Bucket Sort Algorithm: | ||
<pre> | <pre> | ||
Latest revision as of 00:54, 8 July 2016
Any stable sort can solve this problem, using the color as the key: such as insertion sort, merge sort or bucket sort(below)
Bucket Sort Algorithm:
Create 3 buckets, one each for red, blue and yellow. for each Pair P in the input append P.number to the bucket P.color Output the data from the red, blue and yellow buckets.