Skip to content

Commit

Permalink
Merge pull request #101 from mmdmthr/89-big-o-notation-cheatseet
Browse files Browse the repository at this point in the history
89 add article big o notation cheatseet
  • Loading branch information
mmdmthr committed Jul 13, 2024
2 parents 0504ad4 + b452a5f commit 6fc6b8c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions content/blog/2024/07/big-o-notation-cheatseet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: 'Big O Notation Cheatseet'
date: 2024-07-13
category: 'notes'
---

|Notation |Name |Description |Example (Time complexity) |
|---|---|---|---|
| O(1) | Constant complexity | The time and space consumed is consistent regardless of input size | Retrieving a value from a hash table given a specific key |
| O(log n) | Logarithmic complexity | The time and space consumed grows logarithmically with the input size | Binary search on a sorted array |
|O(n) | Linear complexity | The time and space consumed grows in direct proportion to the input size | Searching for a single element in an array (looping over an array) |
| O(n log n) | Linearithmic complexity | The time and space consumed grows proportionally to n log n (where n is the size of the input) | Efficient sorting algorithms like quicksort |
| O(n^2) | Quadratic complexity | The time and space consumed grows with the square of the input size | simple sorting algorithms like bubble sort. looping over an array, and comparing the current element with all other elements in the array |
| O(n^3) | Cubic complexity | The time and space consumed grows with the cube of the input size | Triple nested loops |
| O(2^n) | Exponential complexity | The time and space consumed doubles with eacch increment to the input size | Recursive calculation if Fibonacci numbers |
| O(n!) | Factorial complexity | The time and space consumed grows factorially to the size of the input | Solving the traveling salesman problem with brute force |

0 comments on commit 6fc6b8c

Please sign in to comment.