Write an algorithm for sorting cards with colors on them into piles of same color
Answers
Answered by
3
Answer:
This is an example of an algorithm for sorting cards with colors on them into piles of the same color:
Explanation:
- Pick up all of the cards.
- Pick a card from your hand and look at the color of the card.
- If there is already a pile of cards of that color, put this card on that pile.
- If there is no pile of cards of that color, make a new pile of just this card color.
- If there is still a card in your hand, go back to the second step.
- If there is not still a card in your hand, then the cards are sorted. You are done.
Similar questions