A high-performance laboratory for mastering Data Structures and Algorithms. This repository features industrial-grade templates, optimized competitive programming solutions, and structured implementations.
Tip
Click on the icons or headers to navigate to the specific modules.
|
Progressive problem-solving through the CP-31 curated list.
|
Modular, reusable templates for core DSA.
|
|
Collection of solutions from various OJs.
|
The "Must-Do" classics categorized by topic.
|
To maintain high performance and code clarity, all competitive programming solutions in this repository utilize a Triple-Layer Architecture. This decouples I/O stream synchronization from the core algorithmic logic.
Our implementations focus on cache efficiency and generic usability.
- Segment Tree: Supports vEB (van Emde Boas) layout for better CPU cache locality. Level-aware combine logic allows for complex range queries.
Note
Performance Optimization (vEB Layout):
By arranging nodes in a van Emde Boas layout, this implementation significantly reduces CPU cache misses compared to the traditional
- Splay Tree: A self-adjusting BST that moves frequently accessed nodes to the root.
- Shortest Path:
Dijkstra,Bellman-Ford - MST:
Prim's,Kruskal's - Connectivity:
Kosaraju(SCC)
| Template | Build | Query | Space |
|---|---|---|---|
| Segment Tree | |||
| Splay Tree |
* Denotes amortized time complexity.
Our Segment Tree is highly flexible, allowing for custom combine logic and level-aware operations.
// Example: Range Sum
std::vector<int> arr = {1, 2, 3, 4, 5};
SegmentTree<int> st(arr);
int sum = st.query(1, 3); // Returns 9 (2 + 3 + 4)
st.update(2, 10); // Update index 2 to value 10The Splay Tree is ideal for scenarios where recently accessed elements need to be retrieved quickly.
// Example: Self-adjusting BST
SplayTree tree = {10, 20, 30, 40};
tree.insert(25); // Inserts 25 and splays it to the root
bool found = tree.contains(20); // Moves 20 to the root if found
tree.erase(30); // Removes 30 and restructures optimally