2314a19586
The trie example had some issues; * It did not follow the code convention in CONTRIBUTING.md * The createTrieNode used an inefficient zeroing method (looping over the entries) which also does not zero out holes in the structure (e.g. an alternative would be to use "*node = &(TrieNode){0}", but calloc does all that anyway * It used an inefficient and clumsy printArray method * It used strlen inside the algorithm; this new method could get rid of any strlen/strnlen usage (inserts/searches could be sanitized by snprintf) * This version can allow for a custom mapping function, e.g. if NULL is a valid separator (say that you want a trie for certain binary packages) * The previous version actually contained out-of-bounds array indexing; there were no checks for out-of-bound indexing and words in the word list did contain out of bounds words. It's a surprise it was working so well. * This version just returns 'int' to allow for error checks (instead of a printf inside the algorithm), and uses double pointers for return values (good practice) * The usage example contained unnecessary mallocs, switched that out for scanf. The example is just an example after all, in real applications you'd have better input sanitazion. |
||
---|---|---|
.github | ||
.vscode | ||
audio | ||
client_server | ||
conversions | ||
data_structures | ||
developer_tools | ||
exercism | ||
games | ||
geometry | ||
graphics | ||
greedy_approach | ||
hash | ||
leetcode | ||
machine_learning | ||
misc | ||
numerical_methods | ||
project_euler | ||
searching | ||
sorting | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
.gitpod.dockerfile | ||
.gitpod.yml | ||
CMakeLists.txt | ||
CODE_OF_CONDUCT.md | ||
CodingGuidelines.md | ||
CONTRIBUTING.md | ||
DIRECTORY.md | ||
Doxyfile | ||
LICENSE | ||
README.md | ||
REVIEWER_CODE.md |
The Algorithms - C
Overview
The repository is a collection of open-source implementations of a variety of algorithms implemented in C and licensed under GPLv3 License. The algorithms span a variety of topics from computer science, mathematics and statistics, data science, machine learning, engineering, etc.. The implementations and their associated documentations are meant to provide a learning resource for educators and students. Hence, one may find more than one implementation for the same objective but using different algorithm strategies and optimizations.
Features
- The repository provides implementations of various algorithms in one of the most fundamental general purpose languages - C.
- Well documented source code with detailed explanations provide a valuable resource for educators and students alike.
- Each source code is atomic using standard C library
libc
and no external libraries are required for their compilation and execution. Thus the fundamentals of the algorithms can be studied in much depth. - Source codes are compiled and tested for every commit on the latest versions of three major operating systems viz., Windows, MacOS and Ubuntu (Linux) using MSVC 16 2019, AppleClang 11.0 and GNU 7.5.0 respectively.
- Strict adherence to C11 standard ensures portability of code to embedded systems as well like ESP32, ARM Cortex, etc. with little to no changes.
- Self-checks within programs ensure correct implementations with confidence.
- Modular implementations and OpenSource licensing enable the functions to be utilized conveniently in other applications.
Documentation
Online Documentation is generated from the repository source codes directly. The documentation contains all resources including source code snippets, details on execution of the programs, diagrammatic representation of program flow, and links to external resources where necessary. Click on Files menu to see the list of all the files documented with the code.
Documentation of Algorithms in C by The Algorithms Contributors is licensed under CC BY-SA 4.0
Contributions
As a community developed and maintained repository, we welcome new un-plagiarized quality contributions. Please read our Contribution Guidelines.