树的深度优先,广度优先遍历(栈和队列)

public void DFS(TreeNode root) {深度优先 Stack<TreeNode> stack = new Stack<>(); stack.add(root); while (!stack.isEmpty()) { // 移除最后一个 TreeNode tempNode =
posted @ 2020-12-22 14:37  soft.push("zzq")  Views(329)  Comments(0Edit  收藏  举报