Classic data structures implemented from scratch in Kotlin, for learning and practice. Each structure is a small, self-contained class with no external libraries.
All in src/dataStructures/ unless noted.
| Category | Structures |
|---|---|
| Lists | SinglyLinkedList, DoublyLinkedList, CircularLinkedList, LinkedList (generic, with += / -= operators) |
| Stacks and queues | Stack, Queue, Deque, PriorityQueue (with PQElement), plus StackUnderflowException and QueueUnderflowException |
| Trees | BinaryTree, BinarySearchTree, AVLTree, RedBlackTree, and a generic BST in src/genericDataStructures/ |
| Heaps | Heap |
| Hashing | HashTable, HashMap |
| Graphs | Graph |
The project is a plain IntelliJ IDEA Kotlin module (no Gradle or Maven).
git clone https://github.com/NinjaShadowBoy/DataStructuresWithKotlin.git- Open the folder in IntelliJ IDEA (it includes the Kotlin plugin).
- Set a JDK as the project SDK if prompted.
- Run
src/Main.kt, which builds aLinkedListand adds and removes items.AVLTree.kt,RedBlackTree.ktandgenericDataStructures/BST.ktalso have their ownmain()demos: click the run icon next to them.
With the command-line Kotlin compiler instead:
kotlinc src -include-runtime -d ds.jar
java -cp ds.jar MainKt # the LinkedList demo
java -cp ds.jar dataStructures.AVLTreeKt # the AVL tree demo