Skip to content

Commit 606227b

Browse files
authored
Update data_structures.md
1 parent 940666b commit 606227b

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed

notes/data_structures.md

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,7 @@ In computer science, a _collection_ (often interchangeably referred to as a _con
77

88
Every developer should really get to know collections well. It helps you pick the right type of collection for the job, making your code faster, more efficient, and easier to manage in the long run.
99

10-
```mermaid
11-
flowchart TD
12-
Start((Start))
13-
Start --> OrderImportant{Order is Important?}
14-
15-
%% Order‐important branch
16-
OrderImportant -- yes --> LIFO{Last In, First Out?}
17-
LIFO -- yes --> stack[stack]
18-
LIFO -- no --> FIFO{First In, First Out?}
19-
FIFO -- yes --> queue[queue]
20-
FIFO -- no --> BestIn{Best In, First Out?}
21-
BestIn -- yes --> priority_queue[priority_queue]
22-
BestIn -- no --> KeepSorted{Keep Sorted Elements?}
23-
24-
KeepSorted -- yes --> MainPurpose{Main Purpose}
25-
KeepSorted -- no --> InsertMiddle{Insert/erase at middle?}
26-
27-
InsertMiddle -- yes --> Frequent{Frequent Traversals?}
28-
InsertMiddle -- no --> InsertFront{Insert/erase at front?}
29-
30-
Frequent -- yes --> list[list]
31-
Frequent -- no --> InsertFront
32-
33-
InsertFront -- yes --> deque[deque]
34-
InsertFront -- no --> Persistent{Persistent Positions?}
35-
36-
Persistent -- yes --> deque
37-
Persistent -- no --> SizeVaries{Size varies widely?}
38-
39-
SizeVaries -- yes --> deque
40-
SizeVaries -- no --> vector[vector]
41-
42-
MainPurpose -- "In-order Traversals" --> sorted_vector["vector (sorted)"]
43-
MainPurpose -- "Look-up Keys" --> Lookup{Look-up Keys?}
44-
45-
%% Order-not-important & lookup branch
46-
OrderImportant -- no --> Lookup
47-
Lookup -- no --> InsertFront
48-
Lookup -- yes --> AllowDup{Allow Duplicates?}
49-
50-
AllowDup -- no --> Sep1{Separate Key/Value?}
51-
AllowDup -- yes --> Sep2{Separate Key/Value?}
52-
53-
Sep1 -- yes --> unordered_map[unordered_map]
54-
Sep1 -- no --> unordered_set[unordered_set]
55-
56-
Sep2 -- yes --> unordered_multimap[unordered_multimap]
57-
Sep2 -- no --> unordered_multiset[unordered_multiset]
58-
59-
```
10+
![image](https://github.com/user-attachments/assets/2471c93c-297e-486d-89ea-e78e7241cfb2)
6011

6112
### Linked Lists
6213

0 commit comments

Comments
 (0)