Create find_inorder_successor.py

This commit is contained in:
marina 2023-08-03 13:01:04 -07:00 committed by GitHub
parent 3d8bf7d339
commit abbad25ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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