A suite of interactive data structures and algorithms implemented in C/C++. Interactive web terminal: https://data-structures.xyz/
This is a collection of implementations and interactive visualisers of classic data structures and algorithms in C.
This repository contains the backend code for the web terminal interface here.
Use incognito mode to prevent any chrome extensions from interfering with the formatting and avoid resizing the window.
View my notes here!
Watch a video demo here.
When connected to CSE servers, just copy and paste these commands onto the terminal and hit enter after pasting each one:
git clone https://github.com/Tymotex/Tactile-DS.git && cd Tactile-DS
./util/scripts/make_recurse.sh .
cd linked-list/iterative-version
or cd linked-list/recursive-version
./testLinkedList <space separated integers>
- initially constructs a linked list from the supplied sequence of integers. Eg. ./testLinkedList 42 10 4 20
cd binary-tree
./testTree <space separated integers>
- initially constructs a tree from the supplied sequence of integers. Eg. ./testTree 6 3 10 1 4 8 12 7 9
cd avl-tree
./testTree <space separated integers>
- initially constructs an AVLtree from the supplied sequence of integers. Eg. ./testTree 1 2 3 4 5 6 7
cd splay-tree
./testTree <space separated integers>
- initially constructs a splay tree from the supplied sequence of integers. Eg. ./testTree 5 3 8 7 4
cd unweighted-graph
./testGraph <num vertices>|<input file>
- creates an empty graph with the specified number of vertices OR constructs a graph with edges specified in an input file. Eg. ./testGraph 10
or ./testGraph tests/1.in
cd unweighted-digraph
./testGraph <num vertices>|<input file>
- creates an empty graph with the specified number of vertices OR constructs a graph with edges specified in an input file. Eg. ./testGraph 10
or ./testGraph tests/1.in
cd weighted-graph
./testGraph <num vertices>|<input file>
- creates an empty graph with the specified number of vertices OR constructs a graph with edges specified in an input file. Eg. ./testGraph 10
or ./testGraph tests/1.in
cd weighted-digraph
./testGraph <num vertices>|<input file>
- creates an empty graph with the specified number of vertices OR constructs a graph with edges specified in an input file. Eg. ./testGraph 10
or ./testGraph tests/1.in
cd hash-table
./testHash <size>
- creates an empty hash table with the specified size (otherwise defaults to 10 slots). Eg. ./testHash 12
cd heap
./testHeap <size>
- creates an empty hash table with the specified size (otherwise defaults to 10 slots). Eg. ./testHeap 12
cd sorting-algos
./generate-tests -n <num random files> <list of sizes>
. Eg. ./generate-tests -n 5 10 100 1000
./testSort <filename>
- takes in a file containing a sequence of numbers. Eg. ./testSort tests/random100_1
or ./testSort --silent tests/random_100_1
To get Tactile-DS running locally:
git clone https://github.com/Tymotex/Tactile-DS.git && cd Tactile-DS
- downloads this repository and changes directory to the project root directorybundle install
in the root directory to install Ruby dependencies. See the ruby bundler. This project uses Ruby v2.7.0./util/scripts/make_recurse.sh
- recursively runs make
on all subdirectories. This automatically compiles all the data structuresruby terminal-menu.rb
- starts the selection menu where all the interactive visualisers can be accessedInstructions for testing/deploying the web-based version:
sh server.sh --start
- runs the terminal sharing web service. Access at localhost:8080
. Use nohup sh server.sh --start &
to start the server as a background processsh server.sh --stop
- kills the web terminal server processAlternatively, run the following commands to run Tactile-DS in a Docker
container.
git clone https://github.com/Tymotex/Tactile-DS.git
cd Tactile-DS
docker build -t tactile-ds
docker run -p 8080:8080 tactile-ds
An interactive linked list builder written in C. Supports standard operations (iteratively and recursively) such as insertion, deletion, searching, sorting and reversing.
Implementation for each command is viewable in linked-list.c
and linked-list.h
in the linked-list/iterative-version
and linked-list/recursive-version
directories. View the source code here.
An interactive binary search tree builder written in C. Supports standard operations such as insertion, deletion, rotation, and in-order, pre-order, post-order and level-order printing.
Implementation for each command is viewable in tree.c
and tree.h
in the binary-tree
directory. View the source code here.
An interactive AVL tree builder written in C. Supports AVL insertion, AVL deletion and commands to print the height of each node and the height balance of each node.
Implementation for each command is viewable in tree.c
and tree.h
in the avl-tree
directory. View the source code here.
An interactive splay tree builder written in C. Splay trees differ from regular BSTs in that searching and inserting a value involves bringing the target/inserted node to the root.
Implementation for each command is viewable in tree.c
and tree.h
in the splay-tree
directory. View the source code here.
Interactive unweighted directed/undirected graph builder written in C.
Implementation for each command is viewable in graph.c
, graph.h
, graph-algos.c
and graph-algos.h
in the unweighted-graph
and unweighted-digraph
directories.
Interactive weighted directed/undirected graph builder written in C. Implements Dijkstra’s algorithm for determining a single source spanning tree.
Implementation for each command is viewable in graph.c
, graph.h
, graph-algos.c
, graph-algos.h
, dijkstra.c
and dijkstra.h
in the weighted-graph
and weighted-digraph
directories.
Interactive hash table written in C for storing key-value pairs.
Implementation for each command is viewable in hash-table.c
and hash-table.h
in the hash-table
directory. View source code here.
Interactive max heap table written in C.
Implementation for each command is viewable in heap.c
and heap.h
in the heap
directory. View source code here.
A collection of classic sort algorithms written in C. Timing data is shown for each sort algorithm used.
Implementation for each command is viewable in sort.c
and sort.h
in the sorting-algos
directory. View source code here.