A personal collection of classic data-structure implementations in C, Java and Python.
Explore the repository »
Report Bug
·
Request Feature
Table of Contents
DataStructures gathers hand-written implementations of the classic abstract data types —
lists, stacks, queues, hash tables, skip lists, graphs, heaps and trees — across three
languages. It started as the coursework for the Estructura de Dades (Data Structures)
course of the Computer Science degree at Universitat Rovira i Virgili (URV)
(2019–2020) and has been extended since with a small object-oriented list hierarchy in
Python and a double-ended queue in Java.
Each structure is implemented from first principles (no standard-library containers) and ships with its own runnable test driver, so the repository doubles as a study reference for how each structure is built and exercised.
The three language trees are independent; pick the one you want and build only that.
C (C99, built with
gcc)Java (IntelliJ project, Java 8+)
Python 3
GNU Make (one
makefileper C module)
C/ classic structures in C, each folder with its own makefile + test driver
java/ IntelliJ project with three sub-projects
python/ small object-oriented List / LinkedList hierarchy
C/
| Module | Structure | Extras / driver |
|---|---|---|
ArrayList/ |
Dynamic array list | Sorting & search-cost exercise (ArrayListTest.c) |
Stack/ |
Generic stack (pila) and a real-valued stack |
Reverse-Polish-notation calculator (rpn.c, rpn_reals.c) |
Queue/ |
Stacks and queues (pilas, colas) |
main.c demo |
CircularQueue/ |
Circular queue (cua) built on top of the stack |
Pascal-triangle generator (trianglePascal.c) |
DoubleLinkedList/ |
Doubly linked list | Student Manager interactive CLI that persists to a file |
HashTable/ |
Hash table with chaining (thash) |
Driver that loads keys from datos_hash.txt |
SkipList/ |
Probabilistic skip list | Randomised insert / search / delete test |
includes/ |
Shared helpers: commonlib, random, ErrorCodes.h |
— |
java/
| Sub-project | Contents |
|---|---|
DoubleQueue/ |
Double-ended queue with a static (array) and a dynamic (linked) implementation; Main uses it for palindrome checking |
Graph_Heap/ |
Generic graph + binary heap; Main loads Pajek .net networks from data/ (airports, US power grid, world-trade web, URV e-mail) |
Huffman/ |
Generic list ADT + iterator and a Huffman tree / coder |
python/
List(abstract base class) withArray/ArrayImpl,ArrayListandLinkedList(Node) implementations, plus amain.pydemo.
You only need the toolchain for the language you want to run:
- C — a C compiler and GNU Make
sudo apt install build-essential
- Java — a JDK (11+). The sub-projects are IntelliJ IDEA modules with no build file, so
opening
java/in IntelliJ is the smoothest path;javacon eachsrc/tree also works. - Python — Python 3 (standard library only)
python3 --version
git clone https://github.com/AleixMT/DataStructures
cd DataStructuresEvery module has its own makefile. From inside a module folder:
cd C/Stack
make # build the test / demo binaries
./test # run the stack test driverNotes:
make run(where defined) builds and then runs the module's main binary.C/CircularQueueandC/DoubleLinkedListreference sources underC/StackandC/includes, so keep the tree intact.C/Stack/rpnreads its expression frominput3.txtin the current directory — run it from insideC/Stack/.- Test-driver output is currently in Catalan / Spanish.
Open java/ (or an individual sub-project) in IntelliJ IDEA and run the Main class of the
sub-project you want. Graph_Heap expects java/Graph_Heap as the working directory so it
can find data/*.net.
cd python
python3 main.py- Fix
C/ArrayListinclude path (../_includes/→../includes/) - Fix the conflicting
piladeclaration inC/Queue/pilas.c - Modernise
C/HashTable/main.cfor current compilers (#include <string.h>,getlinebuffer type) - Remove the committed
C/HashTable/mainbinary and add a top-levelmakethat builds every module - Add a real build file (Maven or Gradle) for the Java sub-projects
- Translate the C test-driver output to English and unify the drivers
- Grow the Python side to cover stacks, queues, hash tables and trees like the C and Java trees
See the open issues for the current list.
Contributions are what make the open-source community such an amazing place to learn and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the GNU General Public License v3.0. See LICENSE for more
information.
Aleix Mariné-Tena — aleix.marine.tena@gmail.com — LinkedIn
Project Link: https://github.com/AleixMT/DataStructures
- The Estructura de Dades course and teaching staff at Universitat Rovira i Virgili
- Classmates who collaborated on some of the modules
- Best-README-Template
- Img Shields