Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stack.project</groupId>
<artifactId>stack-app</artifactId>
<groupId>com.treelib.project</groupId>
<artifactId>treelib-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>stack-app</name>
<name>treelib-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
Expand All @@ -28,8 +28,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>22</source>
<target>22</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -40,7 +40,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.stack.project.MainClass</mainClass>
<mainClass>com.treelib.project.MainClass</mainClass>
</manifest>
</archive>
</configuration>
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/com/treelibrary/BST.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.treelibrary;

import java.util.function.Consumer;

public interface BST<T> {

public Node<T> getRoot();
boolean isEmpty();
int count();
Node<T> insert(T data);
Node<T> find(T data);
T remove(Node<T> node);
Node<T> findMin(Node <T> root);
Node<T> findMax(Node <T> root);
Node<T> next(Node<T> node);
Node<T> prev(Node<T> node);

/**
* Traverses the BST in in-order and performs an action on each node.
*
* @param action the action to be performed on each node.
*/
void traverseInOrder(Consumer<T> action);

/**
* Traverses the BST in pre-order and performs an action on each node.
*
* @param action the action to be performed on each node.
*/
void traversePreOrder(Consumer<T> action);

/**
* Traverses the BST in post-order and performs an action on each node.
*
* @param action the action to be performed on each node.
*/
void traversePostOrder(Consumer<T> action);

int height();
void clear();
}
Loading