|
4 | 4 |
|
5 | 5 | #### DS You Must Know
|
6 | 6 |
|
7 |
| -##### ★★★Most Popular Data Structures★★★ |
| 7 | +##### ★★★★★Most Popular Data Structures★★★★★ |
| 8 | + |
8 | 9 | - Array
|
9 | 10 | - Linked List
|
10 | 11 | - Stack
|
11 | 12 | - Queue
|
| 13 | +- Binary Tree |
| 14 | +- Binary Search Tree |
| 15 | + |
| 16 | +##### ★★★★Operation You Can Perform On A Data Structure★★★★ |
| 17 | + |
| 18 | + |
| 19 | +- Delete: Remove an item from the data structure |
| 20 | +- Insert: Add an item to the data structure at any location |
| 21 | +- Merge: Combining the items within data structure A and data structure B into a single one(i.e. call it C) |
| 22 | +- Search: Look up an item's location within the data structure |
| 23 | +- Sort: Arrange items within the data structure in a specific order |
| 24 | +- Traverse: Visit each item in the data structure to perform some operation(e.g. search/sort) |
| 25 | + |
| 26 | + |
| 27 | +##### Big O, Big Omega, Big Theta |
| 28 | + |
| 29 | +- O(n): A Measure of the longest amount of time for an algorithm to complete(...e.g. <=) |
| 30 | + - Used in the worst case |
| 31 | +- Ω(n): A Measure of the shortest amount of time for an algorithm to complete(...e.g. >=) |
| 32 | + - Used in the Best Case |
| 33 | +- Θ(n): A Measure of the average amount of time for an algorithm to complete(...e.g. ==) |
| 34 | + - Used in the Average Case |
| 35 | + |
12 | 36 |
|
13 | 37 | ##### DS Operations
|
14 | 38 |
|
|
22 | 46 |
|
23 | 47 |
|
24 | 48 | 1. Stack
|
| 49 | + |
25 | 50 | - Linear
|
26 | 51 | - LIFO/FILO
|
27 | 52 | - Dinner Plates
|
28 | 53 | - When items are pushed they are placed on the top
|
29 | 54 |
|
30 | 55 | 2. Linked List
|
| 56 | + |
31 | 57 | - Sequential Order
|
32 | 58 | - No Random Access
|
33 | 59 | - Better alternative to Sets because they are dynamic
|
34 | 60 | - Chain of nodes. Every node contains data and a pointer to the subsequent node
|
35 | 61 | - Each unit is called a node
|
36 | 62 | - A Node is composed of data and a pointer
|
37 | 63 | - Last node has a null pointer i.e. the pointer is used but doesn't point to anything
|
| 64 | +- Folders on your computer(i.e. last folder is null because it has no folder within it) |
38 | 65 |
|
39 | 66 | 3. Array
|
| 67 | + |
40 | 68 | - Indexed
|
41 | 69 | - When Size increases performance decreases
|
42 | 70 | - All the elements in the DS must be of the same type
|
| 71 | +- Muffin/Egg Tray |
| 72 | +- Rectangular in shape |
43 | 73 |
|
44 | 74 | 4. Queues
|
| 75 | + |
45 | 76 | - Movie Theatre
|
46 | 77 | - FIFO
|
47 | 78 | - aka people waiting in line
|
| 79 | +- Ordered Collection |
| 80 | +- Operations: add(), remove() |
| 81 | + |
| 82 | + |
48 | 83 |
|
49 | 84 | 5. Hash Table
|
50 |
| -- Contains an index and its corresponding Hash_Value |
51 | 85 |
|
52 | 86 |
|
| 87 | +- Contains an index and its corresponding Hash_Value |
| 88 | +- All items within it are unique |
| 89 | +- Cannot store null as a key nor as a value |
| 90 | +- First parameter within your Hash Table declaration is the data type of the key |
| 91 | +- Second parameter within your Hash Table declaration is the data type of the value |
| 92 | + |
53 | 93 | 6. Trees
|
54 |
| -- hierarchical Structure where data is org in a hierarchy and everything is linked together |
| 94 | + |
| 95 | +- Hierarchical Structure where data is org in a hierarchy and everything is linked together |
55 | 96 | - Not the same as linked list because LL is linear
|
56 | 97 | - Trees are faster to access than a LL because they are non-linear
|
57 | 98 | - Node: person who holds our data
|
| 99 | +- Child Node: person who has a parent |
| 100 | +- Leaf Node: person who has no children |
58 | 101 | - Edge: person who connects two nodes
|
59 | 102 | - Root: Person who is the topmost node
|
60 | 103 | - Node Height: # of edges from the node to the deepest leaf node
|
61 | 104 | - Node Depth: # of edges from the root to the node
|
62 | 105 | - Tree Height: Depth of the deepest node
|
63 | 106 | - Degree of A Node: Total # of branches of that node
|
64 |
| - |
65 |
| - |
66 |
| -7. Heaps |
| 107 | +- Leaves: Person who has no children |
| 108 | +- Use when you want to store items in a hierarchial fashion |
| 109 | +- Quicker to access/search than a LL but slower than an Array |
| 110 | + - Binary Tree |
| 111 | + - Can Have 0,1,2 nodes |
| 112 | + - Binary Search Tree: |
| 113 | + - Used for sorting, getting and searching data |
| 114 | + - Non-linear |
| 115 | + - Arranged in some order |
| 116 | + - no duplicate vals |
| 117 | + - val on the left most subtree of the node is always smaller than the val on its immediate right |
| 118 | +- Node on the left is always less than the node on the right |
| 119 | + |
| 120 | + |
| 121 | +7. Heap |
| 122 | + |
| 123 | +- Special Tree Based DS |
67 | 124 | - Binary Tree
|
| 125 | +- Patients Being Admitted to the Hospital |
| 126 | + - Patients with life-threatning situation get taken care of first |
| 127 | + - Patients that don't have threatening situation wait in line |
68 | 128 | - Parent node makes a comparison with its child nodes and are arranged accordingly
|
| 129 | +- Two Scenarios: |
| 130 | + - Key present at the root node is the greatest among all of its children and successors |
| 131 | + - Key present at the root node is the smallest among all of its children and successors |
69 | 132 |
|
70 | 133 | 8. Graphs
|
| 134 | + |
71 | 135 | - Finite set of vertices, nodes and edges. The edges are what connect one vertex with another
|
72 | 136 | - Graphs are connected in a network form
|
| 137 | +- Non-linear |
| 138 | +- Nodes are the vertices(i.e. endpoints) |
| 139 | +- Edges are the lines/arcs that connect one node with another node |
| 140 | +- Two Types: |
| 141 | + - Directed |
| 142 | + - Undirected |
| 143 | +- Simple Graph: Each edge connects to two different vertices whereby no two edges connect to the same group of vertices |
| 144 | +- Multigraph: An edge can connect to the same pair of vertices |
| 145 | +- |
73 | 146 |
|
74 | 147 |
|
75 | 148 |
|
@@ -137,7 +210,7 @@ But actually the runtime is O(n) because when we calculate runtime we drop the c
|
137 | 210 |
|
138 | 211 | 1. Logarithmic growth slows down as the input size growth i.e d/dx[ln(x)] = 1/x whereas d/dx[2^n]= 2^nln(2)
|
139 | 212 |
|
140 |
| -2. exponential growth as you can see increases at an increasing rate whereas logarithmic growth increases at a decreasing rate |
| 213 | +2. Exponential growth as you can see increases at an increasing rate whereas logarithmic growth increases at a decreasing rate |
141 | 214 |
|
142 | 215 | 3. However, exponential growth becomes slow sooner than logarithmic growth
|
143 | 216 |
|
|
0 commit comments