mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 12:16:14 -04:00
22 lines
269 B
Python
22 lines
269 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# author: bt3gl
|
|
|
|
|
|
def successor(root):
|
|
|
|
root = root.right
|
|
while root:
|
|
root = root.left
|
|
|
|
return root
|
|
|
|
|
|
def predecessor(root):
|
|
|
|
root = root.left
|
|
while root:
|
|
root = root.right
|
|
|
|
return root
|