Data Structure Uses Flashcards
1
Q
Array
A
- Use when you need constant-time random access to elements.
- Suitable for situations where the size of the data is fixed or known in advance.
2
Q
ArrayList
A
- Similar to an array, but provides dynamic resizing.
- Use when you need a resizable array with constant-time random access.
3
Q
LinkedList
A
- Use when you frequently insert or delete elements from the middle of the list.
- Good for situations where sequential access is more common than random access.
4
Q
Stack
A
- Use when you need Last In, First Out (LIFO) access pattern.
- Useful for managing function calls, undo/redo functionality, and parsing expressions.
5
Q
Queue
A
- Use when you need First In, First Out (FIFO) access pattern.
- Suitable for tasks like managing tasks in a printer queue, breadth-first search, etc.
6
Q
Binary Trees
A
- Use for hierarchical data representation.
- Suitable for scenarios where you need efficient searching, insertion, and deletion operations.
7
Q
HashSet
A
- Use when you need constant-time average complexity for basic operations (add, remove, contains).
- Good for scenarios where you want to check for the presence of an element without duplicates.
8
Q
Heap
A
- Use when you need quick access to the maximum or minimum element.
- Often used in priority queue implementations, where the highest (or lowest) priority element needs to be retrieved quickly.