File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
2. Performance of Arrays And Objects Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ // BUILT-IN DATA STRUCTURES
2+ // Through the lens of Big O
3+
4+ // Objects
5+ // Unordered key value pairs
6+ // When to use objects
7+ // When you don't need order
8+ // When you need fast access / insertion and removal
9+
10+ // Big O of Objects
11+ // Insertion - O(1)
12+ // Removal - O(1)
13+ // Searching - O(N)
14+ // Access - O(1)
15+
16+ // Big O of Object Methods
17+ // Object.keys - O(N)
18+ // Object.values - O(N)
19+ // Object.entries - O(N)
20+ // hasOwnProperty - O(1)
21+
22+ // Arrays
23+ // Ordered lists!
24+ // WHEN TO USE ARRAYS
25+ // When you need order
26+ // When you need fast access / insertion and removal (sort of....)
27+
28+ // Big O of Arrays
29+ // Insertion - It depends....
30+ // Removal - It depends....
31+ // Searching - O(N)
32+ // Access - O(1)
33+
34+ // Big O of Array Operations
35+ // push - O(1)
36+ // pop - O(1)
37+ // shift - O(N)
38+ // unshift - O(N)
39+ // concat - O(N)
40+ // slice - O(N)
41+ // splice - O(N)
42+ // sort - O(N * log N)
43+ // forEach/map/filter/reduce/etc. - O(N)
44+
45+ // Limitations of Arrays
46+ // Inserting at the beginning is not as easy as we might think!
47+ // There are more efficient data structures for that!
Data-Structure-And-Algorithm-Notes
Big O Notation Big O Notation Performance of Arrays and Objects You can’t perform that action at this time.
0 commit comments