A library of common data structures and algorithms written in C.

Overview
C Algorithms

The C programming language includes a very limited standard library in
comparison to other modern programming languages.  This is a collection of
common Computer Science algorithms which may be used in C projects.

The code is licensed under the ISC license (a simplified version of the BSD
license that is functionally identical).  As such, it may legitimately be
reused in any project, whether Proprietary or Open Source.

Issues
  • Extended hash_table_iter_next function

    Extended hash_table_iter_next function

    Added a flag to decide HashTableValue.

    • Flag VALUE instructs hash_table_iter_next to return value.
    • Flag KEY instructs hash_table_iter_next to return the key.
    • Flag KEY_VALUE instructs hash_table_iter_next to return both key value pair.

    KeyValue Pair is held in array[2] where array[0] is the key and array[1] is the value.

    opened by losintikfos 9
  • Add license title

    Add license title

    It's not strictly required, but it's useful metadata, and part of the recommended license template text (see http://choosealicense.com/licenses/isc/ and https://opensource.org/licenses/isc-license)

    opened by waldyrious 4
  • Refactored HashTableEntry to hold its Key and Value in a struct pointer object KeyValuePair.

    Refactored HashTableEntry to hold its Key and Value in a struct pointer object KeyValuePair.

    The reason for this is to:

    • Return both the Key and Value in composite
    • Have function hash_table_iter_next(..) return KeyValuePair object holding the composite of Key and Value without the extra call to lookup the value using HashTableKey.
    • Makes the interface cleaner.
    opened by losintikfos 3
  • Cannot modify data of list entry. Was this meant to be this way?

    Cannot modify data of list entry. Was this meant to be this way?

    There are functions to get the value of a ListEntry, but there are no functions to write to the data of a ListEntry.

    The underlying struct is defined in the list.c file so it is not possible to access it directly.

    I am willing to implement the feature if needed.

    opened by TheStefan 2
  • Added algorithms for DFS,BFS,BST,CheckingForBST,Tree

    Added algorithms for DFS,BFS,BST,CheckingForBST,Tree

    DFS -Depth First Search for graphs BFS - Breadth First Search for graphs BST - Binary Search Tree CheckingForBST - Check if a given Tree is a Binary Search Tree Tree - Implementation of tree.

    invalid 
    opened by sujanchegu 1
  • Add validation check of input parameters

    Add validation check of input parameters

    check the sanity of pointers as input parameters.

    I am wondering whether it is necessary to add a callback function to free the ListValue when the entries are removed.

    opened by hexingb 1
  • missing rb_tree_subtree_height implemention

    missing rb_tree_subtree_height implemention

    Hi there, During wrapping this into a python libraty, I found rb_tree_subtree_height missing in rb-tree.c, which appears in the header file. Did I miss something?

    opened by synodriver 2
  • [bug] rb-tree: Calling the comparator on node values instead of keys

    [bug] rb-tree: Calling the comparator on node values instead of keys

    https://github.com/fragglet/c-algorithms/blob/17cd712ef84948ce5c3faae911bc797ebad26e09/src/rb-tree.c#L377

    This line should check the keys, not the values.

    Separately, does this repro accept new features such as implementing the missing deletion functionality in rbtree?

    Thanks!

    opened by donaldong 0
  • Cannot distinguish between no-op insert and memory error

    Cannot distinguish between no-op insert and memory error

    I preface that I'm quite new to C so this may be completely off. However, in:

    https://github.com/fragglet/c-algorithms/blob/5b0555f4aa832a9d4c8662316994faa80f52ae93/src/set.c#L256-L275

    the 0 return value is used both for an operation that does not change the state of a set (because the value already exists), which may or may not be an issue, and a memory error, which is more likely to be an issue, and of a different type.

    Shall the former not use a kind of custom error code, and the latter an ENOMEM according to https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html ?

    Thanks.

    opened by scossu 0
  • Might it be a good idea to add splint annotations to the source code?

    Might it be a good idea to add splint annotations to the source code?

    Splint is a static code analysis tool, splint works with annotations. These annotations help you to do two things, it defines how functions behaves and which assumptions on input are made. Using splint memory leaks might be detected.

    The only downside is that it is a lot of work to go through all code. But maybe it is possible to implement it data structure by data structure in a separate branch untill all structures are done.

    opened by TheStefan 0
Releases(c-algorithms-1.2.0)
  • c-algorithms-1.2.0(Apr 26, 2015)

    • The license has been changed to the ISC license.
    • Support for compiling with gcc coverage options and running tests in valgrind.
    • All headers now have extern "C" definitions for use in C++ programs.
    • Trie free function uses a non-recursive algorithm to avoid the possibility of stack overflow.

    Test suite:

    • Framework added for testing memory allocation/free.
    • Tests have been fixed to properly free any memory allocated during execution of the test.
    • Tests have been expanded to increase the code coverage.
    • A test case has been added for testing use of the program in C++ programs.

    Bugs fixed:

    • Memory leak in hash table.
    • Bugs with the AVL tree.
    • Trie responds to out of memory scenarios correctly.
    Source code(tar.gz)
    Source code(zip)
    c-algorithms-1.2.0.tar.gz(448.15 KB)
  • c-algorithms-1.1.0(Apr 26, 2015)

    • Added data structures:
      • Binary Heap
      • Binomial Heap
      • Bloom Filter
    • Iterator functions changed to a model based around an iterator structure rather than callback functions.
    • Void pointers used for keys/values replaced by typedefs to void pointers. This allows the type to be changed to something else if desired.
    • Hash table sizes changed to use a set of recommended prime numbers that are mathematically good for use in hash tables: http://planetmath.org/encyclopedia/GoodHashTablePrimes.html
    • Tests added for some code that was not covered by the test suite.
    • Failed malloc() calls are now checked for.
    • Bugs fixed:
      • Lockup with set_remove function.
      • set_to_array did not include all values.
    Source code(tar.gz)
    Source code(zip)
    c-algorithms-1.1.0.tar.gz(412.03 KB)
  • c-algorithms-1.0.0(Apr 26, 2015)

Several algorithms and data structures implemented in C++ by me (credited to others where necessary).

Algorithms This repository contains my implementations of several algorithms and data structures in C++ (credited to others where necessary). It has i

Petar Veličković 575 Aug 3, 2022
Fundamentals of Data structures and algorithms in c++

Data Structures & Algorithms About the repository: Contains theories and programming questions related to fundamentals of data structures and algorith

fifu 41 Aug 8, 2022
Algorithms & Data structures in C++.

Algorithms & Data Structures in C++ 目标 ( goal ) : 经典的算法实现 (classical algorithms implementations) 服务器端 (based on linux/gcc) 正确,易于使用和改造, 一个头文件一个算法,并附带一个

xtaci 4.6k Aug 3, 2022
C++17 (-O2) template for competitive programming algorithms, which contains numerous math algorithms.

cpplibForCP C++17 (-O2) template for competitive programming algorithms, which contains numerous math algorithms. Aims: build a stable, fast, easy-to-

null 25 Aug 1, 2022
CXXGraph is a Header-Only C++ Library for Graph Representation and Algorithms

CXXGraph is a small library, header only, that manages the Graph and it's algorithms in C++. In other words a "Comprehensive C++ Graph Library".

ZigRazor 151 Aug 10, 2022
Header-only C++ library for robotics, control, and path planning algorithms.

Header-only C++ library for robotics, control, and path planning algorithms.

null 341 Aug 2, 2022
c++ library including few algorithms and datastructures

c++ library including few algorithms and datastructures

null 2 Dec 25, 2021
Library for building multi-level indoor routes using routing algorithms.

Library for building multi-level indoor routes using routing algorithms. You can easily construct routing graphs and find the shortest path for optimal indoor navigation.

Navigine 5 Mar 20, 2022
This library contains a set of algorithms for working with the routing graph.

Library for building multi-level indoor routes using routing algorithms. You can easily construct routing graphs and find the shortest path for optimal indoor navigation.

Navigine 5 Mar 20, 2022
IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation.

IntX IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation

Telepati 9 Mar 9, 2022
C++ implementations of well-known (and some rare) algorithms, while following good software development practices

ProAlgos: C++ This project is focused on implementing algorithms and data structures in C++, while following good software engineering practices, such

ProAlgos 469 Jul 28, 2022
Provide building blocks (software, hardware and algorithms) for implementing SLAM using small sensors

RemoteSLAM The purpose of this repo is to provide the building blocks (software drivers, hardware and algorithms) for implementing SLAM systems using

Autonomous Drones Lab, Tel Aviv University 38 Jan 20, 2022
Every week exercises for Introduction to Algorithms and Programming

cen109-algorithms commands to compile and link C and C++ programs gcc filename.c -o executableFileName g++ filename.cpp -o executableFileName filename

null 3 Mar 19, 2022
c language's datastruct and algorithms.

cdsaa 介绍 学习数据结构与算法的C语言实现 主要数据结构 动态字符串 动态数组 单向链表 栈 主要算法 更新中. . . 目录结构 |-- include |---- CArray.h 动态数组 |---- CList.h 单向链表 |---- CStack.h 栈 |---- CString

Ticks 1 Nov 24, 2021
Snowball compiler and stemming algorithms

Snowball is a small string processing language for creating stemming algorithms for use in Information Retrieval, plus a collection of stemming algorithms implemented using it.

Snowball Stemming language and algorithms 582 Aug 2, 2022
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.

The Algorithms - C # {#mainpage} Overview The repository is a collection of open-source implementation of a variety of algorithms implemented in C and

The Algorithms 14.1k Aug 7, 2022
This repository contains path planning algorithms in C++ for a grid based search.

This repository contains path planning algorithms in C++ for a grid based search.

null 206 Aug 6, 2022
In this project, we implemented twelve different sorting algorithms.

C - Sorting algorithms & Big O In this project, we implemented twelve different sorting algorithms. Tests tests: Folder of test files. Provided by Alx

Nicholas M Mwanza 1 Oct 26, 2021
All basic algorithms for solving problems of CP

All basic algorithms for solving problems of CP

Islam Assanov 1 Nov 14, 2021