modify code structure

pull/6/head
左程云 4 years ago
parent 3b19508d21
commit 6a78267ec5

@ -129,7 +129,7 @@ public class Code02_SerializeAndReconstructTree {
Queue<Node> queue = new LinkedList<Node>(); Queue<Node> queue = new LinkedList<Node>();
queue.add(head); queue.add(head);
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
head = queue.poll(); head = queue.poll(); // head 父 子
if (head.left != null) { if (head.left != null) {
ans.add(String.valueOf(head.left.value)); ans.add(String.valueOf(head.left.value));
queue.add(head.left); queue.add(head.left);

@ -3,22 +3,26 @@ package class07_11;
public class Code07_PaperFolding { public class Code07_PaperFolding {
public static void printAllFolds(int N) { public static void printAllFolds(int N) {
printProcess(1, N, true); process(1, N, true);
System.out.println();
} }
// 递归过程,来到了某一个节点, // 当前你来了一个节点,脑海中想象的!
// i是节点的层数N一共的层数down == true 凹 down == false 凸 // 这个节点在第i层一共有N层N固定不变的
public static void printProcess(int i, int N, boolean down) { // 这个节点如果是凹的话down = T
// 这个节点如果是凸的话down = F
// 函数的功能:中序打印以你想象的节点为头的整棵树!
public static void process(int i, int N, boolean down) {
if (i > N) { if (i > N) {
return; return;
} }
printProcess(i + 1, N, true); process(i + 1, N, true);
System.out.println(down ? "凹 " : "凸 "); System.out.print(down ? "凹 " : "凸 ");
printProcess(i + 1, N, false); process(i + 1, N, false);
} }
public static void main(String[] args) { public static void main(String[] args) {
int N = 3; int N = 4;
printAllFolds(N); printAllFolds(N);
} }
} }

@ -1,8 +1,8 @@
package class08; package class08_12;
import java.util.LinkedList; import java.util.LinkedList;
public class Code06_IsCBT { public class Code01_IsCBT {
public static class Node { public static class Node {
public int value; public int value;

@ -1,8 +1,8 @@
package class08; package class08_12;
import java.util.ArrayList; import java.util.ArrayList;
public class Code03_IsBST { public class Code02_IsBST {
public static class Node { public static class Node {
public int value; public int value;

@ -1,6 +1,6 @@
package class08; package class08_12;
public class Code01_IsBalanced { public class Code03_IsBalanced {
public static class Node { public static class Node {
public int value; public int value;

@ -1,6 +1,6 @@
package class08; package class08_12;
public class Code02_IsFull { public class Code04_IsFull {
public static class Node { public static class Node {
public int value; public int value;

@ -1,8 +1,8 @@
package class08; package class08_12;
import java.util.ArrayList; import java.util.ArrayList;
public class Code04_MaxSubBSTSize { public class Code05_MaxSubBSTSize {
public static class Node { public static class Node {
public int value; public int value;

@ -1,8 +1,8 @@
package class08; package class08_12;
import java.util.ArrayList; import java.util.ArrayList;
public class Code05_MaxSubBSTHead { public class Code06_MaxSubBSTHead {
public static class Node { public static class Node {
public int value; public int value;

@ -1,4 +1,4 @@
package class08; package class08_12;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

@ -1,4 +1,4 @@
package class08; package class08_12;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

@ -1,4 +1,4 @@
package class08; package class08_12;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
Loading…
Cancel
Save