Please enable JavaScript.
Coggle requires JavaScript to display documents.
Algorithms - Coggle Diagram
Algorithms
Big O
The way we analize how efficient algorithms are, without getting lost in details
I don't care if a function takes 300 milliseconds versus 330 milliseconds given 1,000 inputs
-
Big O : a vacuum that sucks in all the unimportant information and just leaves you with the important stuff
-
-
-
Usually if someone talks about Big O and doesn't specify what type they're talking about, it's usually about computational complexity
-
-
Spatial complexity
-
-
-
Logarithmic
for an array of length 10, it'd create 7 arrays
-
Linear
array of length 10, our algorithm will create 10 arrays
-
-
Recursive sort
Merge Sort
-
Big O
log n: the larger the list gets, we get diminishing amounts of more things to do.
Quick Sort
-
It's another divide-and-conquer, recursive algorithm but it takes a slightly different approach
-
Everything that's smaller than the pivot gets put into a "left" list and everything that's greater get's put in a "right" list
-
After those two sorts come back, you concatenate the sorted left list, the pivot, and then the right list (in that order.)
Recursion
Break a large, difficulty problem into small, easy chunks
-
-
-
-
Iterative Sort
Insertion Sort
-
Start by saying index 0 is sorted, everything else isn't
by definition, a list of 1 elem is sorted
-
Big O:
Best case: O(n), usually O(n²)
-
Bubble sort
The bubble sort is a typical first one to do because it matches the human mental model of sorting pretty well
-
-
-