Home Page - YouTube Channel



Algorithm - Simple English Wikipedia, the free encyclopedia

Algorithm

From the Simple English Wikipedia, the free encyclopedia that anyone can change

An algorithm is a step by step list of directions that need to be followed to solve a problem. The instructions should be simple enough so that each step can be done without thinking about it. Algorithms are often used to describe how a computer might solve a problem. But there are algorithms in the real world too. A recipe can be a type of algorithm. It tells what ingredients are needed to make the dish and what steps to follow. If the recipe tells exactly what to do without too much confusion, then it is an algorithm.

Contents

[change] Comparing Algorithms

There is usually more than one way to solve a problem, there may be many different recipes to make a certain dish which look different but end up tasting the same when all is said and done. The same is true for algorithms. However, some of these ways will be better than others. If a recipe needs lots of complicated ingredients that you do not have, it is not as a good as a simple recipe. When we look at algorithms as a way of solving problems, often we want to know how long it would take a computer to solve the problem using a particular algorithm. When we write algorithms, we like our algorithm to take the least amount of time so that we can solve our problem as quickly as possible.

In cooking, some recipes are harder to do than others, because they take more time to finish or have more things to keep track of. It's the same for algorithms, and algorithms are better when they are easier for the computer to do. The thing that measures how hard an algorithm is is called complexity. When we ask how complex an algorithm is, often we want to know how long it will take a computer to solve the problem we want to

[change] Sorting by colors

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

  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.
  5. Go back to the second step.

[change] Sorting by numbers

This is an example of an algorithm for sorting a stack of cards with many different numbers, so that the numbers are in order.

Players start with a stack of cards that haven't been sorted. Call this "stack A". Players are also going to make a "stack B", but it starts with no cards in it. Then follow these steps:

  1. Take a card from stack A.
  2. If there are no cards in stack B, put the card that was taken in stack B.
  3. If a person still has the card, see if it has a higher or lower number than the card on the top of stack B.
  4. If a card has a higher number than the one on top of stack B, put the card on top of stack B.
  5. If a card has a lower number than the one on top of stack B, or if the numbers are equal, put the card under the top card on stack B, and remember that this was done.

When a player runs out of cards in stack A:

  • If a player did not put any cards under another card when he or she has followed those steps, the player is done.
  • If the player did, move stack B to stack A and start over.

[change] Putting algorithms together

If players have cards with colors and numbers on them, they can sort them by color and number if they do the "sorting by colors" algorithm, then do the "sorting by numbers" algorithm to each colored stack, then put the stacks together.

The sorting by numbers algorithm is harder to do than the sorting by colors algorithm, because they may have to do the steps again many times. They would say that sorting by numbers is more complex.

Wikipedia HTML 2008 in other languages

100 000 +

Česká (Czech)  •  English  •  Deutsch (German)  •  日本語 (Japanese)  •  Français (French)  •  Polski (Polish)  •  Suomi (Finnish)  •  Svenska (Swedish)  •  Nederlands (Dutch)  •  Español (Spanish)  •  Italiano (Italian)  •  Norsk (Norwegian Bokmål)  •  Português (Portuguese)  •  Română (Romanian)  •  Русский (Russian)  •  Türkçe (Turkish)  •  Українська (Ukrainian)  •  中文 (Chinese)

10 000 +

العربية (Arabic)  •  Български (Bulgarian)  •  Bosanski (Bosnian)  •  Català (Catalan)  •  Cymraeg (Welsh)  •  Dansk (Danish)  •  Ελληνικά (Greek)  •  Esperanto  •  Eesti (Estonian)  •  Euskara (Basque)  •  Galego (Galician)  •  עברית (Hebrew)  •  हिन्दी (Hindi)  •  Hrvatski (Croatian)  •  Magyar (Hungarian)  •  Ido  •  Bahasa Indonesia (Indonesian)  •  Íslenska (Icelandic)  •  Basa Jawa (Javanese)  •  한국어 (Korean)  •  Latina (Latin)  •  Lëtzebuergesch (Luxembourgish)  •  Lietuvių (Lithuanian)  •  Latviešu (Latvian)  •  Bahasa Melayu (Malay)  •  Plattdüütsch (Low Saxon)  •  Norsk (Norwegian Nynorsk)  •  فارسی (Persian)  •  Sicilianu (Sicilian)  •  Slovenčina (Slovak)  •  Slovenščina (Slovenian)  •  Српски (Serbian)  •  Basa Sunda (Sundanese)  •  தமிழ் (Tamil)  •  ไทย (Thai)  •  Tiếng Việt (Vietnamese)

1 000 +

Afrikaans  •  Asturianu (Asturian)  •  Беларуская (Belarusian)  •  Kaszëbsczi (Kashubian)  •  Frysk (Western Frisian)  •  Gaeilge (Irish)  •  Interlingua  •  Kurdî (Kurdish)  •  Kernewek (Cornish)  •  Māori  •  Bân-lâm-gú (Southern Min)  •  Occitan  •  संस्कृत (Sanskrit)  •  Scots  •  Tatarça (Tatar)  •  اردو (Urdu) Walon (Walloon)  •  יידיש (Yiddish)  •  古文/文言文 (Classical Chinese)

100 +

Nehiyaw (Cree)  •  словѣньскъ (Old Church Slavonic)  •  gutisk (Gothic)  •  ລາວ (Laos)