ukpagrace
ukpagrace
JCHJava Community | Help. Code. Learn.
Created by ukpagrace on 11/11/2024 in #java-help
How do I write a unit test for an in order traversal of a binary tree
Java
public void inOrder(){
InOrderTraverse(root);
}

private void inOrderTraverse(TreeNode root){
If( root != null){
inOrderTraverse(root.left);
System.out.print(root.val + “—>”);
inOrderTraverse(root.right);
}
}
Java
public void inOrder(){
InOrderTraverse(root);
}

private void inOrderTraverse(TreeNode root){
If( root != null){
inOrderTraverse(root.left);
System.out.print(root.val + “—>”);
inOrderTraverse(root.right);
}
}
18 replies