Skip to main content

Algorithm

In Turkish
Algoritma
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/algorithm

In short

An algorithm is a finite, step-by-step set of instructions for solving a problem or completing a task, such as sorting a list or finding the shortest route.

What is an algorithm?

An algorithm is a precise recipe for turning an input into a desired output. It spells out every step clearly enough that anyone, or any computer, following it will get the same result. Algorithms exist independently of programming languages: the same algorithm can be written in Python, in JavaScript, or on paper.

A cooking recipe is a good everyday analogy for an algorithm. It lists ingredients (the input), gives ordered steps, and ends with a finished dish (the output). In software, familiar examples include binary search, which finds an item in a sorted list by repeatedly cutting the list in half, and the sorting algorithms behind functions like Array.prototype.sort.

Different algorithms can solve the same problem with very different efficiency. Developers compare them using Big O notation, which describes how running time or memory use grows as the input gets larger. For example, checking every item in a list one by one is O(n), while binary search is O(log n), which is far faster for large lists.

An algorithm is not the same thing as a program. The algorithm is the idea, the logical sequence of steps, while a program is a concrete implementation of one or more algorithms in a specific language, together with everything else needed to run it.

At a glance

An algorithm for finding the largest number: take the first number as the largest so far, compare each next number with it and keep the bigger one, and when no numbers are left the one kept is the answer. Run on 7, 3, 9, 4, it answers 9.input73941Take the first numberas the largest so far.2For each next number:if it is bigger, keep it instead.3When none are left,the one kept is the answer.step by steplook atlargest so far77379949output: 9
The steps are finite and exact, so any person or computer following them gets the same answer, in any language. Here every number is looked at once: O(n).

Key takeaways

  • An algorithm is a finite, ordered set of steps that turns an input into an output.
  • It is language-independent; code is just one way to express it.
  • Efficiency is described with Big O notation for time and memory.
  • Classic examples include searching, sorting, and shortest-path algorithms.

Example

Binary search in JavaScriptjavascript
// Find target in a sorted array; return its index or -1
function binarySearch(sorted, target) {
  let low = 0;
  let high = sorted.length - 1;
  while (low <= high) {
    const mid = Math.floor((low + high) / 2);
    if (sorted[mid] === target) return mid;  // found it
    if (sorted[mid] < target) low = mid + 1; // search the right half
    else high = mid - 1;                     // search the left half
  }
  return -1; // not found
}

binarySearch([2, 5, 8, 12, 16], 12); // 3

Readers ask

What is the difference between an algorithm and a program?

An algorithm is the abstract sequence of steps for solving a problem. A program is a concrete implementation of that algorithm, usually along with many others, written in a specific programming language so a computer can run it.

What is Big O notation?

Big O notation describes how an algorithm's running time or memory use grows as the input size grows. For example, O(n) means the work grows in direct proportion to the input, while O(1) means it stays the same no matter how large the input is.

Do I need to know algorithms to be a developer?

You don't need to memorize every algorithm, but understanding common ones like searching and sorting, and knowing how to reason about efficiency, helps you write faster code. Algorithm questions are also common in technical interviews.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings