Data Structures Flashcards
1
Q
Data structures
A
These are standardized patterns of code designed to organize one or more variables
2
Q
Arrays
A
- core to most languages
- linear collection of variables of same size and often type
- reserves memory so their contents are adjacent
- fixed size
- fixed length that can only be set once (array has to reserve that memory)
- access all contents using index
3
Q
Vectors / Lists
A
- used if you don’t care about memory adjacency, and need collection that can grow and shrink as needed
- flexible in size
- memory is not reserved at initialization
- often just a wrapper around an array
- can access elements by an index
- internally doubles in size when full
- adding/removing elements causes elements to shift
4
Q
Stacks
A
- LIFO
- flexible in size
- new elements are added to the top of the stack. Can only retrieve the top element
- good for order
5
Q
Queues
A
- FIFO
- Queues add new elements to bottom
- good for scheduling
6
Q
Linked Lists
A
- a linear collection without an index
- made up of nodes (wrappers around the actual element with a link to the next element)
- accessing particular elements means searching the list
- can be singly or doubly
7
Q
Maps / Dictionaries*
A
- A collection of nodes structures like an array list, but each node is not aware of any others.
- each node both wraps the actual variable or object being stored in the map, and also contains a key value that can be used to refer to the node in question directly