Skip to main content

bst

BST#

  • we can construct 1 unique BST by only pre-order OR post-order Or level-order

  • if node that has to be deleted in BST is having 2 children, then copy the inorder successor of that node

  • we use BST insteadt of array as space when there is insertiona nd deletion involved in the data and we need somehow a sorted array as we keep going

  • The time complexity of above operations in a self-balancing Binary Search Tree (BST) (like Red-Black Tree, AVL Tree, Splay Tree, etc) is O(Logn).

  • lowest common ancestor of BST for the given 2 nodes (use BST property) - https://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/

  • Inorder Tree Traversal without Recursion using stack (it can be used when we want control over each step in inorder) e.g finding comon nodes in 2 BST

  • reverse inOrder traversal is useful when find 2nd largest element