A comprehensive Data Structures and Algorithms (DSA) repository implemented in C. This project contains core data structure implementations (Linked Lists, Stacks, Queues, Binary Trees) alongside practical "Travaux Pratiques" (TPs) that demonstrate these structures in real-world applications, as well as exam exercises. It serves as a reference for students and developers looking to understand and apply DSA concepts effectively.
Please Note: The solutions provided in this repository come from various sources and may not be perfect.
- Some solutions are my own implementations, while others come from professors or other students
- There might be inconsistencies or errors in certain implementations
- Some TPs may lack detailed explanations or may be missing entirely
- This project was organized primarily to help fellow students have a centralized reference
As a student myself, I put this together to help others navigate these concepts. If you find errors or have suggestions for improvements, please feel free to reach out. Remember, the goal is learning!
DSA_TPs/
├── CMakeLists.txt # Main build configuration
├── src/ # Core data structure implementations
│ ├── SinglyLinkedList/ # Singly linked list implementation
│ │ └── SLL.c
│ ├── Stack/ # Stack implementations
│ │ └── Dynamic/
│ │ └── STACK.c
│ ├── Queue/ # Queue implementations
│ │ └── Dynamic/
│ │ └── QUEUE.c
│ ├── BinaryTree/ # Binary tree implementation
│ │ └── BT.c
│ └── dsa.h # Header file for all implementations
├── TP/ # Practical exercises
│ ├── 1_LinkedList_I/ # First linked list exercise
│ │ ├── solution.c
│ │ └── helper.c
│ ├── 2_BinaryTree_I/ # First binary tree exercise
│ │ └── solution.c
│ ├── 3_Stack_I/ # Stack exercises
│ │ └── TP3.c
│ └── ... # Additional exercises
├── Exams/ # Practical exercises
│ ├── Session/ # First linked list exercise
│ │ ├── solution.c
│ │ └── solution.txt
│ └── ...
└── build/ # Generated build files (not committed)
This project includes implementations of:
- Singly Linked Lists
- Stacks (Dynamic and Static)
- Queues (Dynamic and Static)
- Binary Trees
- Binary Search Trees
- Sorting & Searching Algorithms
- Heaps
- Hash Tables
- Graphs (Adjacency List and Matrix)
Each structure comes with core operations like insertion, deletion, traversal, and more — all written in C and applied in practical TPs.
- Compiler: GCC or Clang with C23 support
- Build system: CMake 3.10+
- Operating System: Linux, macOS, or Windows (with WSL)
- Optional: Make (for convenience)
# Clone the repository
git clone https://github.com/HadiHz88/DSA_TPs.git
cd DSA_TPs
# Configure with CMake
cmake -S . -B build -G "MinGW Makefiles"
# Build all targets
cmake --build buildAfter building, executables for each TP will be available in the build/ directory:
# Run the first linked list TP
./build/1_LinkedList_I # Or cmake -G "MinGW Makefiles" -S . -B build
# Run the binary tree TP
./build/2_BinaryTree_I# Only needed when source files change
cmake --build build💡 Tip: You only need to rerun the initial
cmake -S . -B buildcommand if you modify theCMakeLists.txtfile or add new source files.
- Create appropriate directories in
src/ - Implement your
.cand.hfiles - Add the files to
SOURCE_FILESinCMakeLists.txt
- Create a new directory under
TP/, e.g.,TP/3_Queue_I/ - Add your implementation files (e.g.,
solution.c,helper.c) - Update
CMakeLists.txtto build your new TP:
add_executable(3_Queue_I
TP/3_Queue_I/solution.c
TP/3_Queue_I/helper.c # optional
${SOURCE_FILES} # shared data structures
)- Rebuild the project
This project follows these best practices:
- Modularity: Each data structure is independently implemented
- Reusability: Core implementations shared across TPs
- Standard compliance: Follows C23 standards
- Documentation: Code is commented and documented
- Error handling: Robust error checking and handling
Hadi Hijazi Computer Science Student at Lebanese University Passionate about clean code, data structures, and building useful tools.
This project is licensed under the MIT License.
Star ⭐ this repository if you find it useful!