Welcome! This repository is a meticulously organized, "from the ground up" exploration of classic data structures, implemented in modern C++20. Whether you are preparing for technical interviews or deepening your understanding of computer science fundamentals, this project provides clean, educational implementations across a 7-week curriculum.
Explore everything from memory basics to advanced graph algorithms. Each module includes the data structure implementation and a demo application.
| Week | Topic | Key Concepts |
|---|---|---|
| Week 1 | Pointer Basics | Memory handling, pointer arithmetic, addresses. |
| Week 2 | Array Stacks & Queues | Contiguous memory, circular buffers, LIFO/FIFO. |
| Week 3 | Linked Lists | Dynamic allocation, node-based stacks and queues. |
| Week 4 | Hash Tables | Open addressing, hash functions, record management. |
| Week 5 | Binary Search Trees | Recursion, tree traversals (In-order, Pre-order, Post-order). |
| Week 6 | AVL Trees (Balanced) | Advanced: Self-balancing via rotations (LL, RR, LR, RL). |
| Week 7 | Graphs & PageRank | Advanced: Adjacency matrices, Graph traversals, PageRank algorithm. |
If you're looking for the most complex implementations in this project, check these out:
-
AVL Tree Implementation: A self-balancing binary search tree that maintains
$O(\log n)$ performance for all major operations. See it in action: AVL Demo. - PageRank Algorithm: An implementation of the iterative algorithm used by search engines to rank pages, applied to a directed graph represented by an Adjacency Matrix.
- Dynamic Linked Structures: Implementation of stacks and queues using manual node allocation, demonstrating fine-grained memory management in C++.
This project uses CMake for easy building across different environments.
- CMake (3.x or newer)
- C++20-compatible compiler (GCC 10+, Clang 10+, or MSVC 2019+)
- Clone and Enter:
git clone https://github.com/yourusername/data-structures-from-scratch.git cd data-structures-from-scratch - Generate Build Files:
cmake -B build -DCMAKE_BUILD_TYPE=Release
- Build All Targets:
cmake --build build
This project generates individual executables for each week/topic. After building, all binaries are located in the build/output directory.
To build all demos at once:
cmake --build buildTo build a specific demo (e.g., week1_pointer):
cmake --build build --target week1_pointerTo run a specific demo:
./build/output/week1_pointer| Target | Description | Source |
|---|---|---|
week1_pointer |
Pointer Basics & Recursion | src/week1/pointer.cpp |
week2_time |
C++ Classes & Time Management | src/week2/classes/ |
week2_stack |
Vector-based Stack Implementation | src/week2/pilha/ |
week2_queue |
Array-based Circular Queue | src/week2/fila/ |
week3_linkedlist |
Stack & Queue via Linked Lists | src/week3/ |
week4_hash |
Basic Hash Table Implementation | src/week4/ |
week5_tree |
Binary Search Tree (BST) | src/week5/ |
week6_avl |
Self-balancing AVL Tree | src/week6/ |
week7_graph |
Graph with PageRank Algorithm | src/week7/ |
- Educational First: Code is written for readability and learning, not production optimization.
- Modern C++: Leveraging C++20 features where applicable.
- Self-Contained: Each week is a modular step forward in complexity.
Happy coding! Feel free to explore the source and experiment with the implementations.