Thursday, June 14, 2018

Data structure cheat sheet

June 14, 2018

Introduction


It is easy for me to find a data structure cheat sheet. Here is one of them. What I like to do is to list them one by one, and add some notes for each of them what to learn if I have 5 minutes for each of them.

One Data structure a time


I just experienced the terrible mistake on the important meeting, I chose to use wrong data structure minimum heap instead of deque.

One thing I can do is to blog about it. And also I like to build a good habit to try to memorize all the data structures.

30 minutes workout


What I have done is to go over the flow chat to determine the data structure, and then I write down some notes using my own style.

Sometimes I give my choice but I do not show step by step how I get there. It is better to go over these steps, so it is easy for people to follow you.

Julia's notes:

Questions asked:

order is important?

Last in first out?
First in First out?
Largest element first out?

Sorted by key

Insert/erase at front?
Insert/erase in middle?
Insert/erase in middle?

Need to merge collections?
Size will vary widely?
Need to find the nth element

Store key separate to value


Start -> order is important

Order is important

stack
queue
priority_queue

Insert/ erase in middle

list

Insert/ erase at front

Yes -> Need to merge collections No -> deque


Size will vary widely

No - vector
yes - deque

Need to merge collections


No - deque


Data structures:

list
vector
deque
map
set
multi_map
multiset



No comments:

Post a Comment