# Algorithms

URL:: https://brilliant.org/wiki/algorithm/?subtopic=algorithms&chapter=introduction-to-algorithms
Author:: brilliant.org
## Highlights
> An algorithm is a procedure that takes in input, follows a certain set of steps, and then produces an output. Oftentimes, the algorithm defines a desired relationship between the input and output. ([View Highlight](https://read.readwise.io/read/01gagdwgpmawfsa9r347e652my))
> Learning about algorithms is essential to being a successful computer programmer, and understanding them can help give you an idea of how computers work. ([View Highlight](https://read.readwise.io/read/01gagdx2vkw7x0e1hj9zerbfgz))
> [Data structures](https://brilliant.org/wiki/linear-data-structures/) were the answer. Their invention and research is paralleled by, and is often taught alongside, algorithms. ([View Highlight](https://read.readwise.io/read/01gagdyfbwkhcjkgp42a29feqb))
> Algorithm Properties:
> 1. Time complexity. This is the time an algorithm takes to complete, and it is often given using [big O notation](https://brilliant.org/wiki/big-o-notation/) with its input as the independent variable. For example, if we want to search a card in the sorted nnn cards, we can do in logarithmic time, and the time complexity would be O(log(n))O\big(\log(n)\big)O(log(n)).
> 2. Space complexity. This is the space (in computer memory) the algorithm uses during its execution. Again, if we're sorting nnn cards, and we need to make an extra array of size nnn for each card to do so, the space complexity would be O(log(n2))O\big(\log(n^2)\big)O(log(n2)).
> 3. Correctness. An algorithm is correct if and only if, for every input, it halts and outputs the correct output. Contrary to what you might think, algorithms that are not correct are sometimes useful. For example, [partially correct algorithms](https://brilliant.org/wiki/partially-correct-algorithms/) only guarantee that if the algorithm halts, the answer will be correct. ([View Highlight](https://read.readwise.io/read/01gagdyrfqxds9rsf5mew0frk8))
> A **high-level description** ([View Highlight](https://read.readwise.io/read/01gagdzkws156k69esqgbjbnz8))
> **Formal definition**. A formal definition will often give the input and output of the algorithm in formal mathematical terms. ([View Highlight](https://read.readwise.io/read/01gagdzsgt08r77bv6a7bj3m33))
> **Pseudo-code**. ([View Highlight](https://read.readwise.io/read/01gagdzyqyt6611kg9es6vdw9g))
> **Implementation**. An implementation in a given language will be a piece of code that is understandable and runnable by a computer ([View Highlight](https://read.readwise.io/read/01gage02hs03xz26tqsv7kt09b))
---
Title: Algorithms
Author: brilliant.org
Tags: readwise, articles
date: 2024-01-30
---
# Algorithms

URL:: https://brilliant.org/wiki/algorithm/?subtopic=algorithms&chapter=introduction-to-algorithms
Author:: brilliant.org
## AI-Generated Summary
An algorithm is a procedure that takes in input, follows a certain set of steps, and then produces an output. Oftentimes, the algorithm defines a desired relationship between the input and output. For example, if the problem that we are trying to solve is sorting a hand of cards, the problem might be defined as follows: This last part is very important, it's the meat and substance of the algorithm. And, as an algorithm designer, …
## Highlights
> An algorithm is a procedure that takes in input, follows a certain set of steps, and then produces an output. Oftentimes, the algorithm defines a desired relationship between the input and output. ([View Highlight](https://read.readwise.io/read/01gagdwgpmawfsa9r347e652my))
> Learning about algorithms is essential to being a successful computer programmer, and understanding them can help give you an idea of how computers work. ([View Highlight](https://read.readwise.io/read/01gagdx2vkw7x0e1hj9zerbfgz))
> [Data structures](https://brilliant.org/wiki/linear-data-structures/) were the answer. Their invention and research is paralleled by, and is often taught alongside, algorithms. ([View Highlight](https://read.readwise.io/read/01gagdyfbwkhcjkgp42a29feqb))
> Algorithm Properties:
> 1. Time complexity. This is the time an algorithm takes to complete, and it is often given using [big O notation](https://brilliant.org/wiki/big-o-notation/) with its input as the independent variable. For example, if we want to search a card in the sorted nnn cards, we can do in logarithmic time, and the time complexity would be O(log(n))O\big(\log(n)\big)O(log(n)).
> 2. Space complexity. This is the space (in computer memory) the algorithm uses during its execution. Again, if we're sorting nnn cards, and we need to make an extra array of size nnn for each card to do so, the space complexity would be O(log(n2))O\big(\log(n^2)\big)O(log(n2)).
> 3. Correctness. An algorithm is correct if and only if, for every input, it halts and outputs the correct output. Contrary to what you might think, algorithms that are not correct are sometimes useful. For example, [partially correct algorithms](https://brilliant.org/wiki/partially-correct-algorithms/) only guarantee that if the algorithm halts, the answer will be correct. ([View Highlight](https://read.readwise.io/read/01gagdyrfqxds9rsf5mew0frk8))
> A **high-level description** ([View Highlight](https://read.readwise.io/read/01gagdzkws156k69esqgbjbnz8))
> **Formal definition**. A formal definition will often give the input and output of the algorithm in formal mathematical terms. ([View Highlight](https://read.readwise.io/read/01gagdzsgt08r77bv6a7bj3m33))
> **Pseudo-code**. ([View Highlight](https://read.readwise.io/read/01gagdzyqyt6611kg9es6vdw9g))
> **Implementation**. An implementation in a given language will be a piece of code that is understandable and runnable by a computer ([View Highlight](https://read.readwise.io/read/01gage02hs03xz26tqsv7kt09b))