You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Rule 1: Worth Case
* Rule 2: Remove Constants
* Rule 3: Different terms for inputs
* Rule 4: Drop Non Dominants
Big O Cheat Sheet:
Big Os
* O(1) Constant - no loops
* O(log N) Logarithmic - usually searching algorithms have log n if they are sorted (Binary Search)
* O(n) Linear - for loops, while loops through n items
* O(n log(n)) Log Liniear- usually sorting operations
* O(n^2) Quadratic - every element in a collection needs to be compared to ever other element. Two
* nested loops
* O(2^n) Exponential - recursive algorithms that solves a problem of size N
* O(n!) Factorial - you are adding a loop for every element\ *- Iterating through half a collection is still O(n)
* Two separate collections: O(a \_ b)
* Rule 1: Always worst Case
* Rule 2: Remove Constants
* Rule 3: Different inputs should have different variables. O(a+b). A and B arrays nested would be O(a\*b) for steps in order for nested steps
* Rule 4: Drop Non-dominant terms
What causes Space complexity?-
Variables
Data Structures
Function Call
Allocation
1 . How to build One
2. How to Use it
* CPU - Central processing unit
* RAM - Random Access memory
* Storage - Storage is something you use to put your stuff in
6. Data Structures Arrays
What is an Array?
Arrays are a data structure that stores values in a contiguous block of memory. Each element in the array is accessed by its index. The index of the first element is 0 and the index of the last element is the length of the array minus 1.
[] Hash Table is a data structure that stores data in an associative manner.
[] It is a collection of key-value pairs.
[] It uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.
Hash Table is a data structure that stores data in an associative manner.
It is a collection of key-value pairs.
It uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.
Key
Value
0
Julian
1
Alex
2
Bob
3
Kevin
4
Rob
Name
Time Complexity
lookup
O(1)
insert
O(1)
delete
O(1)
search
O(1)
*can be O(n)
Hash Table
consthash=(key,arrayLen)=>{lettotal=0;for(letcharofkey){// map "a" to 1, "b" to 2, "c" to 3, etc.letvalue=char.charCodeAt(0)-96;total=(total+value)%arrayLen;}returntotal;};console.log(hash('pink',10));// 0console.log(hash('orangered',10));// 7console.log(hash('cyan',10));// 3
Master the Coding Interview: Data Structures + Algorithms The ultimate coding interview bootcamp to help you ace your coding interviews and land your dream job. You'll not only learn data structures and algorithms but also the exact steps to take to get more interviews, more job offers, and a higher salary.