1000個併發執行緒,10臺機器,每臺機器4核,設計執行緒池大小
阿新 • • 發佈:2020-10-26
二叉樹圖解
二叉樹的前序遍歷
前序遍歷:先輸出父節點,再遍歷左子樹和右子樹
//前序遍歷 根左右
public void preSearch() {
System.out.println(this);
if (this.left != null) {
this.left.preSearch();
}
if (this.right != null) {
this.right.preSearch();
}
}
二叉樹的中序遍歷
中序遍歷: 先遍歷左子樹,再輸出父節點,再遍歷右子樹
//中序遍歷 左根右
public void midSearch() {
if (this.left != null) {
this.left.midSearch();
}
System.out.println(this);
if (this.right != null) {
this.right.midSearch();
}
}
二叉樹後續遍歷
後續遍歷:先遍歷左子樹,再遍歷右子樹,最後輸出父節點
//後序遍歷 左右根 public void backSearch() { if (this.left != null) { this.left.backSearch(); } if (this.right != null) { this.right.backSearch(); } System.out.println(this); }