File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -740,8 +740,28 @@ Delete 15 from BST
740740 on <a href =" https://codepen.io " >CodePen</a >.</span >
741741</p >
742742<script async src =" https://cpwebassets.codepen.io/assets/embed/ei.js " ></script >
743+
743744#### Find the In-Order successor in a given BST?
744745
746+ ![ ] ( https://i.imgur.com/DRdvkOc.png )
747+
748+ ** Case 1:** If Node has right sub-tree. Then go deep to left-most node in right subtree or find the min in the right subtree.
749+
750+ ![ ] ( https://i.imgur.com/pTdpX87.png )
751+
752+
753+ ** Case 2:** If Node has no right child then go to the nearest ancestor for which given node would be in the left tree.
754+
755+ ![ ] ( https://i.imgur.com/29oVu7S.png )
756+
757+ Example: Find in-order successor of ` 12 ` ?
758+
759+ ![ ] ( https://i.imgur.com/HPsr9tu.png )
760+
761+ Example: Find in-order successor of ` 6 ` ?
762+
763+ ![ ] ( https://i.imgur.com/ejvIFs0.png )
764+
745765[ Question] ( https://codepen.io/roopkt/pen/YzZdMxa )
746766
747767<p class =" codepen " data-height =" 265 " data-theme-id =" dark " data-default-tab =" js,result " data-user =" roopkt " data-slug-hash =" YzZdMxa " style =" height : 265px ; box-sizing : border-box ; display : flex ; align-items : center ; justify-content : center ; border : 2px solid ; margin : 1em 0 ; padding : 1em ;" data-pen-title =" Find In-order Successor in BST Question " >
You can’t perform that action at this time.
0 commit comments