This project implements binary & red-black trees with nodes that can be added and removed. The nodes are implementations of the Node class, and the tree is printed using the BinaryNodePrinter or ColoredNodePrinter class.
- Lombok: A Java library that helps to reduce boilerplate code. Lombok
- Maven: A build automation tool used for managing project dependencies. Maven
src/
├── main/
│ ├── java/
│ │ └── dev/
│ │ └── haguel/
│ │ ├── node/
│ │ ├── service/
│ │ └── starter/
| | └── tree/
│ └── resources/
└── test/
src/main/java/dev/haguel/node/: Contains theSimpleNodeandColoredSimpleNodeclasses.src/main/java/dev/haguel/service/: Contains utility classes.src/main/java/dev/haguel/starter/: Contains the main starter classes likeRedBlackTreeStarter.src/main/java/dev/haguel/tree/: Contains the tree interface and implementation.
addNode(Node<T, T> toAdd): Adds a node to the binary tree.removeNode(): Removes a node from the binary tree.getTree(): Returns a copy of the tree.setRight(Node<T, T> right): Sets the right child of the node.setLeft(Node<T, T> left): Sets the left child of the node.setParent(Node<T, T> parent): Sets the parent of the node.getKey(): Returns the key of the node.getValue(): Returns the value of the node.getRight(): Returns the right child of the node.getLeft(): Returns the left child of the node.findNode(): Finds and returns the current node.findNodeByKey(T key): Finds and returns a node with the specified key.findNodeByValue(V value): Finds and returns a node with the specified value.
- Implements Node interface
- Implements Node interface
print(SimpleNode<T> node): Prints the binary tree.
print(ColoredSimpleNode<T> node): Prints the red-black tree tree.