n=int(input())
t={}
for i in range(n):
a,b,c=map(str,input().split())
t[a]=[b,c] #left, right 자식
def preorder(root):
if root!=".":
print(root,end="")
preorder(t[root][0])
preorder(t[root][1])
def inorder(root):
if root!=".":
inorder(t[root][0])
print(root,end="")
inorder(t[root][1])
def postorder(root):
if root!=".":
postorder(t[root][0])
postorder(t[root][1])
print(root,end="")
preorder('A')
print()
inorder('A')
print()
postorder('A')
'백준 풀이' 카테고리의 다른 글
백준 1764번 파이썬 (집합) (0) | 2022.09.01 |
---|---|
백준 2108번 파이썬 (Counter 함수) (0) | 2022.09.01 |
백준 14889번 파이썬 (백트레킹) (0) | 2022.09.01 |
백준 1753번 파이썬(다익스트라) (0) | 2022.08.31 |
백준 1011번 파이썬 (0) | 2022.08.31 |