mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Create find_inorder_successor.py
This commit is contained in:
parent
3d8bf7d339
commit
abbad25ed8
18
trees/find_inorder_successor.py
Normal file
18
trees/find_inorder_successor.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# author: bt3gl
|
||||||
|
|
||||||
|
|
||||||
|
def find_inorder_successor(root):
|
||||||
|
|
||||||
|
successor = None
|
||||||
|
|
||||||
|
while root:
|
||||||
|
|
||||||
|
if root.val <= p.val:
|
||||||
|
root = root.right
|
||||||
|
else:
|
||||||
|
successor = root
|
||||||
|
root = root.left
|
||||||
|
|
||||||
|
return successor
|
Loading…
x
Reference in New Issue
Block a user