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!
- Interactive Linked List
- Interactive Binary Search Tree
- Interactive AVL Tree
- Interactive Splay Tree
- Interactive Unweighted Graph (Directed and Undirected)
- Interactive Weighted Graph (Directed and Undirected)
- Interactive Hash Table
- Interactive Heap
- Sorting Algorithms Benchmarker
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 .
- You now have access to all the interactive data structures. The commands to run each of them are:
- Linked Lists:
cd linked-list/iterative-version
orcd 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
- Binary Search Tree:
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
- AVL Tree:
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
- Splay Tree:
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
- Graphs:
- Unweighted
- Undirected
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
- Directed
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
- Undirected
- Weighted
- Undirected
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
- Directed
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
- Undirected
- Unweighted
- Hash Table:
cd hash-table
./testHash <size>
- creates an empty hash table with the specified size (otherwise defaults to 10 slots). Eg../testHash 12
- Heap:
cd heap
./testHeap <size>
- creates an empty hash table with the specified size (otherwise defaults to 10 slots). Eg../testHeap 12
- Sorting Algorithms:
cd sorting-algos
- Optional: generate sequences using:
./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
- Linked Lists:
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 directory- Install GoTTy
- Run
bundle 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 runsmake
on all subdirectories. This automatically compiles all the data structuresruby terminal-menu.rb
- starts the selection menu where all the interactive visualisers can be accessed
Instructions for testing/deploying the web-based version:
sh server.sh --start
- runs the terminal sharing web service. Access atlocalhost:8080
. Usenohup sh server.sh --start &
to start the server as a background processsh server.sh --stop
- kills the web terminal server process
Alternatively, 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.
- View source code for unweighted graphs algorithms here and basic functions here
- View source code for unweighted digraphs algorithms here and basic functions here
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.
- View source code for weighted graphs algorithms here, basic functions here and Dijkstra's algorithm here
- View source code for weighted digraphs algorithms here, basic functions here and Dijkstra's algorithm here
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.