일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- springboot3.x
- 라즈베리파이3
- CSS
- Algorythm
- NAV
- HTML
- MongoDB
- bootstrap
- raspberrypi
- 라즈베리파이3b+
- 라즈비안
- Python
- 트리
- 13237
- 2909
- 백준
- dp
- algotythm
- 파이썬
- 크롤링
- dynaminprogramming
- node.js
- 알고리즘
- nav-tab
- Crawling
- 16.04
- 2579
- baekjun
- 라즈베리파이
- ubuntu
Archives
- Today
- Total
노트
[백준] 1991번 트리 순회 python 본문
n = int(input())
tree = {}
for _ in range(n):
root, left, right = input().split()
tree[root] = [left,right]
def preorder(a):
if a is not '.':
print(a,end='')
preorder(tree[a][0])
preorder(tree[a][1])
def inorder(a):
if a is not '.':
inorder(tree[a][0])
print(a,end='')
inorder(tree[a][1])
def postorder(a):
if a is not '.':
postorder(tree[a][0])
postorder(tree[a][1])
print(a,end='')
preorder('A')
print()
inorder('A')
print()
postorder('A')
'알고리즘' 카테고리의 다른 글
[백준] 14493번 과일노리 python (1) | 2023.10.01 |
---|---|
[백준] 2579번 계단 오르기 python (0) | 2023.09.22 |
[백준] 15903번 카드 합체 놀이 python (0) | 2023.09.03 |
[백준] 1197번 최소 스패닝 트리 python (0) | 2023.08.20 |
[백준] 2775번 부녀회장이 될테야 python (0) | 2023.08.13 |
Comments