12
12
* Best-case performanceO(1)
13
13
* Average performance O(n)
14
14
*
15
- * @author abir (https://github.com/abircb)
16
15
*/
17
16
18
17
public class DepthFirstSearch {
@@ -35,14 +34,12 @@ public static <T extends Comparable<T>> T find(T key, BinaryTree<T> tree) {
35
34
* The BinaryTree class defines the structure of a binary tree
36
35
* Also contains a static nested class called TreeNode
37
36
* @param <T>
38
- * @author abir
39
37
*/
40
38
class BinaryTree <T extends Comparable <T >> {
41
39
42
40
private TreeNode <T >root ;
43
41
44
42
/**
45
- * @author abir
46
43
* @param <P>
47
44
* This class defines what a node in a binary tree looks like
48
45
*/
@@ -87,10 +84,10 @@ private void add(TreeNode<P> node) {
87
84
* @return the tree node corresponding to the key
88
85
*/
89
86
private TreeNode <P >find (P key ) {
90
- if (key .compareTo (this .key ) ==0 )return this ;
87
+ if (key .compareTo (this .key ) ==0 )return this ;
91
88
92
89
else if (key .compareTo (this .key ) <0 ) {
93
- if (this .left ==null )return null ;
90
+ if (this .left ==null )return null ;
94
91
else return this .left .find (key );
95
92
}
96
93