Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikhil-jindal12/avltree
Contains the implementation for an AVLTree with a generic type as the key.
https://github.com/nikhil-jindal12/avltree
avl-tree inorder-traversal java-8 javadoc-documentation postorder-traversal preorder-traversal
Last synced: about 1 month ago
JSON representation
Contains the implementation for an AVLTree with a generic type as the key.
- Host: GitHub
- URL: https://github.com/nikhil-jindal12/avltree
- Owner: nikhil-jindal12
- Created: 2023-10-20T19:05:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-21T03:59:18.000Z (11 months ago)
- Last Synced: 2024-09-30T13:01:44.285Z (about 2 months ago)
- Topics: avl-tree, inorder-traversal, java-8, javadoc-documentation, postorder-traversal, preorder-traversal
- Language: Java
- Homepage: https://nikhil-jindal12.github.io/AVLTree/
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AVLTree
There are two classes in the repository, the `AVLTree.java` & `AVLTreeTest.java` classes. `AVLTree.java` contains the implementation for an AVL tree that uses a generic type for the key. The `AVLTreeTest.java` is a testing class which tests the various methods in the `AVLTree.java` file and prints out the results to the terminal.
---
The following methods are in the `AVLTree.java` class:
- `void preOrder(AVLTreeNode tree)` - prints a preorder traversal of the tree to the terminal from the specified node
- `void inOrder(AVLTreeNode tree)` - prints an in-order traversal of the tree to the terminal from the specified node
- `void postOrder(AVLTreeeNode tree)` - prints a post-order traversal of the tree to the terminal from the specified node
- `AVLTreeNode minimum(AVLTreeNode tree)` - finds the smallest node of the AVL tree from the specified root
- `AVLTreeNode maximum(AVLTreeNode tree)` - finds the largest node of the AVL tree from the specified root
- `AVLTreeNode insert(AVLTreeNode tree, T key)` - inserts an element into the tree with given key and returns the root node
- `AVLTreeNode remove(AVLTreeNode tree, AVLTreeNode z)` - deletes the node (z), and then returns the root node----
The `AVLTreeTest.java` prints the following operations to the terminal in this order:
1. Input the sequence
2. Print out preOrder traversal
3. Print out inOrder traversal
4. Print out postOrder traversal
5. Print out the height of the tree
6. Print the smallest node of the tree
7. Print the largest node of the tree
8. Print the details of the tree
---
9. Delete one node
10. Print the height of the tree after the deletion
11. Print out inOrder traversal after the deletion
12. Print the details of the tree again
---
13. Add one node
14. Print out preOrder traversal after the addition