mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-30 04:36:08 -04:00
Create bt_postorder.py
This commit is contained in:
parent
0e2b6b39b0
commit
096185a6e8
11
trees/bt_postorder.py
Normal file
11
trees/bt_postorder.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# author: bt3gl
|
||||||
|
|
||||||
|
def postorder(root) -> list:
|
||||||
|
|
||||||
|
if root is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
return postorder(root.left) + postorder(root.right) + [root.val]
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user