Ask a Teacher
what is an algorithm? |
An algorithm is a set of instructions, sometimes called a procedure or a function, that is used to perform a certain task. This can be a simple process, such as adding two numbers together, or a complex function, such as adding effects to an image. In computer programming, there are often many different ways -- algorithms -- to accomplish any given task. Each algorithm has advantages and disadvantages in different situations. Sorting is one place where a lot of research has been done, because computers spend a lot of time sorting lists. Here are five different algorithms that are used in sorting:
If you have a million integer values between 1 and 10 and you need to sort them, the bin sort is the right algorithm to use. If you have a million book titles, the quick-sort might be the best algorithm. By knowing the strengths and weaknesses of the different algorithms, you pick the best one for the task at hand. |