Algorithms let us think about computation independently of the limitations of a computer or programming language.
- ๐ Binary Search efficiently finds a target in a sorted list by halving the search range each step.
- ๐๐ Two Pointers uses two indices moving toward each other (or in tandem) to solve array problems in linear time.
- ๐ Sorting reorganizes elements into a specified order (e.g. ascending) using algorithms like quicksort or mergesort.
- ๐ช Sliding Window maintains a window over a sequence to compute metrics (sum, max, etc.) for all subarrays of fixed size in .
- โ Prefix Sums precomputes cumulative sums, allowing us to query any subarray total in constant time.
- โพ๏ธ Recursion solves problems by having functions call themselves on progressively smaller inputs, often simplifying divideโandโconquer.
- ๐ง Breadth First Search explores a graph level by level, ideal for finding shortest paths in unweighted graphs.
- ๐ Depth First Search dives deep along one branch before backtracking, useful for connectivity and topological sort.
- ๐ Dynamic Programming breaks problems into overlapping subproblems, caching results to avoid redundant work.
- ๐บ๏ธ Dijkstraโs Algorithm finds shortest paths from a source in a non-negative weighted graph using a priority queue.
- ๐ข Primโs and Kruskalโs Algorithm greedily builds a minimum spanning tree by selecting the lightest edges without creating cycles.
- ๐ฅฝ Union-Find manages disjoint sets with nearโconstant time union and find operations (useful for connectivity).
- ๐ Randomized Search Tree employs randomness to simplify solutions or improve expected performance on average.
Data Structures
- ๐ Hashmaps store keyโvalue pairs for average lookup, insertion, and deletion.
- ๐ฝ๏ธ Stacks provide a LIFO structure supporting push and pop at one end, handy for backtracking and parsing.
- ๐ Queues provide a FIFO structure supporting enqueue at rear and dequeue from front, ideal for BFS.
- โ๏ธ Linked Lists provide a sequence of nodes where each node points to the next, allowing insertion/deletion with a pointer.
- ๐ Graphs model entities (nodes) and their relationships (edges), foundational for network and connectivity problems.
- ๐ณ Binary Search Trees are binary trees where left child < node < right child, giving search on average.
- โฐ๏ธ Heaps are a treeโbased priority queue that lets us extract the max (or min) in .
- ๐ด Red-Black Tree is a selfโbalancing BST ensuring ) operations by enforcing color and rotation invariants.
- โฎ๏ธ AVL Tree is a heightโbalanced BST with strict balance factor, guaranteeing in worst case.
- ๐ฒ Treap is a randomized BST combining heap priorities with BST keys to maintain balance probabilistically.
- ๐ K-Dimensional Trees partition kโdimensional points recursively, useful for nearest neighbor searches.
- ๐ B-Trees and B+ Trees provide wide, multiโway trees optimized for disk and block storage, minimizing I/O operations.