Data Structures and Algorithms written in C from Algorithms (4th Edition) textbook by Sedgewick & Wayne.
Check index.md for the chapter wise index of data structures and algorithms.
Please ensure you have cmake (minimum version 4.1), make (GNU Make 3.81)
and criterion (for testing) installed on your system.
Clone this repository and cd into the created directory.
git clone https://github.com/shubham-kv/algs4-c/
cd algs4-cThe data structures & algorithms live in the lib directory and the test
executable programs that use them (called as clients) live in the clients
directory.
Build the project with cmake:
cmake -S . -B buildor you can make a build directory, cd into build directory and run
cmake there with no arguments.
In this case cmake makes Makefiles in the build directory for us to use.
Build a specific client for example the graph_paths_client.c in
clients/graph/ by using the make command like the following:
make -C build graph_paths_clientor build the entire project:
make -C buildFind and run the executable from the build/bin/ directory.
An example passing in the arguments:
./build/bin/graph_paths_client dfs tinyG.txt 0Tests live inside the tests directory and all the test files are prefixed
with a test_, for example the test file for graph_paths_bfp.c under
lib/graph/graph_paths_bfp/ is test_graph_paths_bfp.c and to build it run:
make -C build test_graph_paths_bfpor build all the test executables:
make -C build/testsSimply run the output binary from the build/bin/ directory to run your test
(similar to how you would run any other executable file).
Use ctest for a quick run of all the tests after building all the test
executables:
ctest --test-dir buildContributions are Welcome!
Feel free to share your feedback or raise an issue/PR to make any contributions.
Cheers!