BST 的遍历框架

1 void BST(TreeNode root, int target) 
2 {
3     if (root.val == target)
4         // 找到目标,做点什么
5     if (root.val < target) 
6         BST(root.right, target);
7     if (root.val > target)
8         BST(root.left, target);
9 }

 

posted @ 2020-05-08 16:19  Jinxiaobo0509  阅读(128)  评论(0)    收藏  举报