Skip to content

Commit 24cf5bf

Browse files
committed
Merge pull request careermonk#2 from ayusmand/master
Fixed recursive call to toString() method in BinaryTreenode class.
2 parents a48ff74 + 0e73239 commit 24cf5bf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/chapter06trees/BinaryTreeNode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public static boolean findInBT(BinaryTreeNode root, int data) {
7171
// Returns a String representation of this BinaryTreeNode.
7272
public String toString() {
7373
if (isLeaf()) {
74-
return this.toString();
74+
return this.toString1();
7575
}
7676
else {
7777
String root, left = "null", right = "null";
78-
root = this.toString();
78+
root = this.toString1();
7979
if (getLeft() != null) {
8080
left = getLeft().toString();
8181
}

src/chapter06trees/PreOrderRecursive.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
public class PreOrderRecursive {
1616
public void PreOrder(BinaryTreeNode root){
1717
if(root != null) {
18+
System.out.println(root.data);
1819
PreOrder(root.getLeft());
19-
System.out.println(root.data);
2020
PreOrder(root.right);
2121
}
2222
}

0 commit comments

Comments
 (0)