Skip to content

Commit 35bc2e4

Browse files
committed
update binary tree ops
1 parent 320e0f0 commit 35bc2e4

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

BTree/src/BTree.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public BTree(int v) {
2323
public static BTree createMinimalBT(BTree root, int[] array, int s, int e) {
2424
if (s >= 0 && e <= array.length - 1 && s <= e) {
2525
int m = (e + s) / 2;
26-
2726
root = new BTree(array[m]);
2827

2928
root.left = createMinimalBT(root.left, array, s, m - 1);
@@ -74,13 +73,11 @@ public static void showByLevel(BTree root) {
7473
System.out.print(node.right.value + "\t");
7574
}
7675
if (current.isEmpty()) {
77-
current = next;
76+
current.addAll(next);
7877
next.clear();
7978
System.out.println();
8079
}
81-
8280
}
83-
8481
}
8582

8683
public static int width(BTree root) {
@@ -392,7 +389,6 @@ public static void main(String[] args) {
392389
System.out.println("tree size: " + treeSize(t1));
393390
System.out.println("tree 4 smallest: " + k_smallest_element(t1, 4).value);
394391
k_smallest_element1(t1,3);
395-
//System.out.println("tree 4 smallest: " + k_smallest_element1(t1, 2).value);
396392

397393
showByLevel(t1);
398394

@@ -465,7 +461,6 @@ public static void main(String[] args) {
465461
if (nextNode2 != null)
466462
System.out.println(nextNode2.value);
467463

468-
469464
}
470465

471466
}

MathOps/src/MathOps.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public static int divide(int dividend, int divisor) {
6969
while (dividend >= divisor) {
7070
dividend -= divisor;
7171
result++;
72-
7372
}
7473

7574
if (neg_dividend ^ neg_divisor)
@@ -83,8 +82,10 @@ public static int divide1(int dividend, int divisor) {
8382
assert (divisor != 0);
8483

8584
boolean bNeg = false;
85+
8686
if ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0))
8787
bNeg = true;
88+
8889
long la = dividend;
8990
long ula = la < 0 ? -la : la;
9091
long lb = divisor;

0 commit comments

Comments
 (0)