LeetCode|Tree Problem Sets

整体思路框架

关于前序中序后序遍历的思考

二叉树本质上其实就是一个二叉链表,针对二叉树的前序中序后序 递归遍历,我们实际上也可以用在数组和链表当中

1
2
3
4
5
6
7
public void traverseArray(int[] array,int idx){
//递归终止条件
if(idx==array.length){
return;
}
traverseArray(array,idx+1);
}
1
2
3
4
5
6
public void traverseLinkedList(ListNode head){
if(head==null){
return;
}
traverseLinkedList(head.next);
}

LeetCode|Tree Problem Sets
http://example.com/2023/06/11/LeetCode-Tree-Problem-Sets/
作者
Noctis64
发布于
2023年6月11日
许可协议