- Dynamic size
- Ease of insertion/deletion
- Random access is not allowed
- Extra memory is required with each pointer
- Not cache friendly. Since array elements are contiguous locations, there is locality of reference which is not there in case of linked lists.
- Implementation of stack and queue and adjacency list representation of graphs
- Dynamic memory allocation Why?
- Maintaining directory of names
- Image viewer, where images are linked in slideshows
- Previos and next page in web browsers
- Playlist in music players
- Any node can be a starting point
- Easy to go from the last node to the first node
- More memory
- Not easy to reverse the list
- Computers use Circular Linked List to cycle through active applications. Basically Round Robin Scheduling algorithm
- Task queues
- Snake game on Nokia phones
- Never ending playlist
- Can be traversed in both directions
- Deletion is more efficient as we can easily fetch the previous node
- Consumes more space because of extra pointer
- Schedulers in operating systems
- Undo-Redo functionality
- MRU and LRU in operating systems
- Store hierarchial data
- Trie are used in autocompletion and suggestion of words
- BST can be used in searching
- B-Tree and B+ Trees are used in database indexing
- Advantages of BST over Hash Table
- Ternary Search Tree - space efficient Trie
- Heaps are better at finding Min/Max whereas BSTs are finding specific values
- Insertion in heaps is O(1) whereas it is O(log(n)) for BST. This is the killer feature of heaps
- Binary heap creation is O(n) whereas it is O(n log(n)) for BST.
- Search for arbitary element is O(log(n)) in BST whereas it is O(n) for heap. Reference
- Graph algorithms like Djikstra
- Priority queues
For differences between Heap and BST - Reference
Why is binary heap preferred over BST for priority queue
| Graphs | Trees | | --- | --- | --- | | No unique node called root | Has a unique root node | | There can be a cycle | No cycle | | Network model | Hierarchial model |
- Networking
- Social networks to find friends
- Maps
- Finding dependencies (Topological Sort)
- Topological sort -
- Finding dependencies
- Job scheduling among dependent jobs
- Kosaraju's algorithm -
- To find strongly connected components (which are used in social networks)
- Bipartite Graph -
- Student and class scheduling
- Stable marriage
- Text analyzer to cluster documents
- Netflix movie preference algorithm
- Depth First Search -
- For a weighted graph, DFS produces Minimum Spanning Tree
- Cycle check
- Path finding
- Topological Sorting
- Finding strongly connected components
- Breadth First Search -
- For a unweighted graph, BFS produces Minimum Spanning Tree
- Used in BitTorrent to find all neighbour nodes
- Crawlers in search engine Why BFS not DFS is used in web crawlers
- Broadcasting in networking
- Garbage collection. Breadth First Search is preferred over Depth First Search because of better locality of reference.
- Ford-Fulkerson algorithm
- Minimum Spanning Tree -
- Network design (like connecting all offices in a city with the lowest cost of cables)
- Articulation Point -
- Articulation points represent vulnerabilities in a connected network – single points whose failure would split the network into 2 or more disconnected components. They are useful for designing reliable networks.
- Expression handling, infix to postfix etc
- Function calls
- Parenthesis checking
- Backtracking
- BFS traversal
- Handling interrupts in operating system
- IO Buffers, pipes
- Prim's algorithm
- Data compression. Used in Huffman coding