美文网首页
BST - 671. Second Minimum Node I

BST - 671. Second Minimum Node I

作者: 程序猪小羊 | 来源:发表于2018-05-30 10:50 被阅读11次

Binary tree's node's children:
either equal to its value,
or smaller than it.

Therefore, for root node:
it is the smallest of course;

  • if both of its children are bigger than it, then take the MIN(its children).

  • if at least one child equals to it:
    then look down.

Java divide and conquer solution

230. Kth Smallest Element in a BST

Hint:

  1. Try to utilize the property of a BST.
  2. What if you could modify the BST node's structure?
  3. The optimal runtime complexity is O(height of BST).

二叉树遍历

[Leetcode] Binary Tree Traversal 二叉树遍历

Binary Tree Inorder Traversal

[LeetCode] Kth Smallest Element in a BST 二叉搜索树中的第K小的元素

BST的性质:
parent

这又是一道关于二叉搜索树 Binary Search Tree 的题, LeetCode中关于BST的题有Validate Binary Search Tree 验证二叉搜索树Recover Binary Search Tree 复原二叉搜索树Binary Search Tree Iterator 二叉搜索树迭代器Unique Binary Search Trees 独一无二的二叉搜索树Unique Binary Search Trees II 独一无二的二叉搜索树之二Convert Sorted Array to Binary Search Tree 将有序数组转为二叉搜索树Convert Sorted List to Binary Search Tree 将有序链表转为二叉搜索树

相关文章

网友评论

      本文标题:BST - 671. Second Minimum Node I

      本文链接:https://www.haomeiwen.com/subject/wnrtsftx.html