Create bst_pre_sucessor.py

This commit is contained in:
marina 2023-08-03 13:56:53 -07:00 committed by GitHub
parent 2fe870650b
commit e1a2904cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

23
trees/bst_pre_sucessor.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def successor(root):
root = root.right
while root.left:
root = root.left
return root
def predecessor(root):
root = root.left
while root.right:
root = root.right
return root