mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-23 08:51:31 -04:00
Rename bst_sucessor_and_precessor.py to bs_sucessor_and_precessor.py
This commit is contained in:
parent
ef073d11ca
commit
27f5ce1c6f
1 changed files with 0 additions and 0 deletions
23
trees/bs_sucessor_and_precessor.py
Normal file
23
trees/bs_sucessor_and_precessor.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue