
[백준] 5639번 이진 탐색 트리 (C++) - binary search tree
2022. 11. 21. 14:05
solving/C, C++
발상 우선 전위 탐색을 통해 얻은 tree가 주어지므로, 이를 배열에 입력받는다. 그리고 아래 그림과 같은 이분 탐색을 거치면, 후위 탐색으로 배열을 바꿀 수 있다. 전위 탐색 : root -> left -> right 후위 탐색 : left -> right -> root 이므로 순서를 바꾸어준다. 소스코드 #include #include using namespace std; int tree[10001]; void postorder(int start, int end){ if(start == end) { cout