Skip to content

Commit

Permalink
small update on algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
Barnsa committed Sep 22, 2020
1 parent 1396e2f commit 30b4083
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions docs/algorithms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ Another thing that can complicate an algorithms efficiency is how complex the ta

We express complexity with something called "big O notation" (pronounced big-ohh), which describes the worst case scenario for the algorithm and the data inputted, and then express that as a mathematical expression.

### O(1)
<!-- the dollar signs make it an inline math symbol modifier -->
### $O(1)$
This big O notation is representative of something that will always execute with the same amount of time no matter how big the input data is. This could be an algorithm that looks for the first entry in the data for instance, reading the first entry won't change the speed of the algorithm with a larger data set.

### O(N)
### $O(N)$
This describes an algorithm who's complexity grows linearly with the size of the data that is passed to it. The algorithms worst case (O) grows with the amount of data that is passed to it (N). An example of this type of algorithm is trying to match a string to a list of strings. It could conceivably be matched to the first entry of course, but we always take the worst case scenario so if we assume that it always matches the last element of the list, the longer the list is the longer it would take, and hence the more complex.

### O($N^2$)
This describes an algorithm that raises in complexity directly proportional to the square of the data passed to it. This is commonly seen in algorithms with nested conditions, as the data passed to the algorithm would need to be compared twice.
### $O(N^2)$
This describes an algorithm that raises in complexity directly proportional to the square of the data passed to it. This is commonly seen in algorithms with 2 nested conditions, as the data passed to the algorithm would need to be compared twice for each entry.

###
### $O(2^N)$
This describes an algorithm that doubles in complexity for each addition to the input data. The growth of an $O(2^N)$ function is exponential[^3]

[^1]: Obviously you would have to alphabetise strings, try alphabetically sorting numbers... it doesn't go well.
[^2]: If you've ever gotten your younger sibling to make you a hot beverage you might have an inkling of what I mean.
[^2]: If you've ever gotten your younger sibling to make you a hot beverage you might have an inkling of what I mean.
[^3]: Old man rant: Exponential growth is a specific mathematical term used to describe a growth that is directly proportional to the input data volume. Not the media abused version that just means 'more', but they wanted to resonate exponentially intelligent and so misapplied the denomination producing and perpetuating societal misinformation for their own paltry advantage... #sarcasticallytriggered.
2 changes: 1 addition & 1 deletion mk_doc_ultra

0 comments on commit 30b4083

Please sign in to comment.