My notes on different data structures used to solve variety of problems in computer science.
Simple Graphs
No self loops, all edges are distinct.
For an undirected graph :
(|V|₂)
represents the binomial coefficient n choose 2
, which is the number of ways to choose 2 distinct elements from a set of n elements. This gives the maximum possible number of undirected edges in a simple graph with |V| vertices, where each edge connects two distinct vertices without any duplicates.
For a directed graph :
2(|V|₂)
represents twice the binomial coefficient. This is because in a directed graph, for every pair of distinct vertices, there can be two possible edges (one in each direction). So the maximum number of directed edges is twice the maximum number of undirected edges.
More Readings :
Trees
Heap : Heap is a complete binary tree.
-
heappush()
andheappop()
take .heappush()
starts from leaf upto to the root node, andheappop()
in the opposite direction comparing the element with the current node, traversing the height of the tree which .
So for push(siftup
)/pop(siftdown
) we first maintain the complete binary tree property then max/min heap property. -
heapsort is since after each element you pop, elements need to be reordered to maintain the max/min heap property takes
-
Heapify takes wherein it does
siftdown
while generating the heap. Starts with leaf nodes and decides whether or not to swap depending on the child nodes instead of looking at parent nodes in heappush orsiftup
.
Interval Search Trees :
- How do they work?
- Problem solved using the same.
Radix Trees :
- Pruning radix tree
- Corresponding implementation for fast ranked autocompletes.
Balancing a BST
Drawing presentable trees
Appendix
- Data Structures Visualizations
- Challenging data structures and algorithms.
- More Data Structures
- Evaluating data structures : Data Calculator
- Obscure Data Structures
- Data structures for Data Intensive Applications-Tradeoffs and Design Guidelines
- Collections library in python but having sorted containers
- Linked Lists in linux kernel explained.
- Advanced DSA.