Coder Social home page Coder Social logo

libadt's Introduction

libadt - an abstract data types library

BinaryTree

Status

MIT licensed Build Status codecov Codacy Badge

What is libadt?

Libadt is a C library for those who want to study a little more about Abstract Data Types. The library implements the most common types of structures of computer science and is extremely well documented.

ADTs are a theoretical concept in computer science, used in the design and analysis of algorithms, data structures, and software systems, and do not correspond to specific features of computer languages - mainstream computer languages do not directly support formally specified ADTs. However, various language features correspond to certain aspects of ADTs, and are easily confused with ADTs proper; these include abstract types, opaque data types, protocols, and design by contract. -- Wikipedia

Why?

Because in C we deal directly with memory, and the structures provided by the language are quite primitive. And since in higher level languages there are other structures (such as classes and objects) that implement many of the features of data structures, there would be no advantage (or learning) in implementing these structures on such languages.

What Structures do you have now?

  • Singly-linked list (README);
  • Doubly-linked list (README);
  • Deque using doubly-linked list as infrastructure (README);
  • Queues
    • using singly-linked list as infrastructure (README);
    • using deque as infrastructure (README);
  • Stacks
    • using singly-linked list as infrastructure (README);
    • using deque as infrastructure (README);

But this repository is in its very beginning and another structures will come in time.

What structures do you plan to implement?

At the present time, the following structures are being implemented:

  • Circular Linked List (README);

Once completed, the next to be implemented are as follows:

  • Trees (Binary Search Tree, AVL Tree, Red-black Tree);
  • Heaps;
  • Priority Structures (P-Queue, P-Stack and P-Deque);
  • Sets using sorted tree as infrastructure;
  • Stack and Queue using tree as infrastructure;
  • Priority Structures (P-Queue, P-Stack and P-Deque) using sorted tree as infrastructure;
  • Associative Arrays;
  • Sparse Matrixes;
  • Graphs;

Other related algorithms

When we are dealing with data structures, certain code patterns appear in the form of specialized algorithms to work with each type of structure.

With that in mind, we will be adding these algorithms into another folder to avoid confusion between data structures and algorithms that operate on top of these.

Algorithms implemented:

  • Infix to Postfix converter using Stack;
  • Expression evaluator using Queue;
  • Iterators for Lists;

Algorithms being implemented:

  • Sorting
    • Quick Sort
    • Merge Sort

Naming structure

In some data structures, you may notice that there is a prefix the name of each function. The prefixes refer to the structures used to build each structure. For example, stacks and queues use the prefix "sl_" because they use a simple linked list internally, in its implementation. This notation is used because, in the future, there can be other implementations using different support structures such as heaps or trees.

Base Documentation

Dictionary of Algorithms

Future and beyond...

There is no future set. Getting to the point we implement all the most common and important structures, other focuses will be defined, always having its focus on the learning provided to the person who will use these structures.

Have fun!

libadt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

libadt's Issues

Proposal to change function return values and error reporting

Since many data structures functionality makes use of function parameters to return data by a allocated pointer set earlier, and use 'return' to give an elementary error reporting, my proposal is to change functions behaviour to use 'return' to give the relevant data to the caller and, in case of error, return non valid value (NULL, -1, etc) and set errno in the way to permit newbie users a better experience when dealing with functions and its returnings.

Change build chain to cmake

Due to increase on difficulties in write the build scripts, we decide to change them from make to cmake, to ease the construction, the tests and the integration among the other projects.

Fix awkward insert behavior on lists

Analyzing lists tests, strange behavior was detected when you add items when the current variable is not set. The functions that insert use the behavior to add the list of the head when they should offer an option to set the insertion default behavior in this case that the current variable is not set.

Rename examples section to algorithms

Since there are many functions that operate with the data structures, we need to catalog them in a folder more representative than "examples". Using "algorithms" we can classify they more easily by its function or structure usage.

Fix mixed tabs and spaces into codebase

Due to the fact that library development has occurred in several code editors, several files have different tabulations, consisting of tabs or spaces, in different patterns.

Change lists to work with list_node instead of data

Since the objective of this project is to work with abstract data types, the functions that deal with the structures must deal with the node elements instead coupling the node creation/destruction into its logic.

This way, it's needed to decouple node logic from structures logic to permit another types of node structures, like priority signaled nodes.

Fix Makefiles to ease compilation

The actual Makefiles are inefficiente in the way that for every alteration on the project, is needed to create or change build targets. Those targets are almost the same across the various source files.

Add test coverage to code

The way test is performed don't actually guarantee that the code is right and make difficult to understand what is happening on the test code.

The tests should check the consistency of the code in the following situations: leak testing and stress testing.

This way, is proposed to use a test coverage tool to do the unit testing of the data structures using Unity (https://github.com/ThrowTheSwitch/Unity).

Fix problems in build scripts

Some scripts fail to compile if you try to compile using make -f because the Makefile and its includes weren't developed to achieve compilation from outside the project root folder.

Prepare first release

For the first release be placed, we need to resolve the issues #7, #17, #18 and #19. After completion of these issues, we can continue generating a first version of the library.

After these, we will create a v0.1 release tag. For this, we will present the following structures:

  • Singly-linked List;
  • Doubly-linked List;
  • Doubly-circular List;
  • Singly-list-backed Queue;
  • Singly-list-backed Stack;
  • Doubly-list-backed Deque;
  • Deque-backed Queue;
  • Deque-backed Stack;
  • Iterators to iterate through the structures;

Add iterators for lists.

In computer programming, an iterator is an object that enables a programmer to traverse a container, particularly lists. Various types of iterators are often provided via a container's interface. Though the interface and semantics of a given iterator are fixed, iterators are often implemented in terms of the structures underlying a container implementation and are often tightly coupled to the container to enable the operational semantics of the iterator. Note that an iterator performs traversal and also gives access to data elements in a container, but does not perform iteration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.