Computer Science, asked by karanangi66741, 2 months ago

Write an algorithm for sorting cards with colors on them into piles of same color

Answers

Answered by YaseeN6423
3

Answer:

This is an example of an algorithm for sorting cards with colors on them into piles of the same color:

Explanation:

  1. Pick up all of the cards.
  2. Pick a card from your hand and look at the color of the card.
  3. If there is already a pile of cards of that color, put this card on that pile.
  4. If there is no pile of cards of that color, make a new pile of just this card color.
  5. If there is still a card in your hand, go back to the second step.
  6. If there is not still a card in your hand, then the cards are sorted. You are done.
Similar questions