A comprehensive C++ project for implementing and exploring dynamic programming algorithms and solutions.
DynamicPrograming-CPP/
├── CMakeLists.txt # Main CMake configuration
├── CMakePresets.json # CMake presets for different build configurations
├── README.md # This file
├── build.sh # Build script using CMake presets
├── include/ # Header files
├── src/ # Source files
├── tests/ # Test files
└── build/ # Build output directory (generated)
- CMake 3.20 or higher
- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
- Make or Ninja build system
The project includes a build.sh
script that uses CMake presets for easy building:
# Build debug version
./build.sh debug
# Build release version
./build.sh release
# Clean build directory
./build.sh clean
# Show help
./build.sh help
You can also build manually using CMake presets:
# Configure and build debug
cmake --preset debug
cmake --build --preset debug
# Configure and build release
cmake --preset release
cmake --build --preset release
# Debug build
mkdir -p build/debug
cd build/debug
cmake -DCMAKE_BUILD_TYPE=Debug ../..
make -j4
# Release build
mkdir -p build/release
cd build/release
cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j4
After building, the executable will be located in the build directory:
# Debug build
./build/debug/bin/DynamicProgramming
# Release build
./build/release/bin/DynamicProgramming
Run tests using CTest:
# Using presets
cmake --build --preset debug
ctest --preset debug
# Manual
cd build/debug
ctest --output-on-failure
- Add
.cpp
files to thesrc/
directory - Add corresponding header files to the
include/
directory - CMake will automatically detect and include them in the build
- Use C++17 features
- Follow modern C++ best practices
- Include appropriate headers
- Use meaningful variable and function names
- debug: Debug build with Unix Makefiles
- release: Release build with Unix Makefiles
This project can be used to implement various DP algorithms such as:
- Fibonacci sequence
- Knapsack problems
- Longest Common Subsequence (LCS)
- Edit Distance
- Coin Change
- Maximum Subarray Sum
- And many more...
This software is released under the MIT License.