mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-11 00:22:52 -04:00
Update and rename bst_find_inorder_successor.py to bst_find_successor_inorder.py
This commit is contained in:
parent
cba141be6a
commit
5d56bb3855
1 changed files with 1 additions and 1 deletions
18
trees/bst_find_successor_inorder.py
Normal file
18
trees/bst_find_successor_inorder.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
|
||||
def find_successor(root, p):
|
||||
|
||||
successor = None
|
||||
|
||||
while root:
|
||||
|
||||
if root.val <= p.val:
|
||||
root = root.right
|
||||
else:
|
||||
successor = root
|
||||
root = root.left
|
||||
|
||||
return successor
|
Loading…
Add table
Add a link
Reference in a new issue