题目 Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tree. 题解 这题搞了我一个小时!!!好气啊,我们好好…
PAT甲级专题-树的遍历 涉及知识点:树.建树.深度优先搜索.广度优先搜索.递归 甲级PTA 1004 输出每一层的结点,邻接表vector建树后.用dfs.bfs都可以边搜边存当前层的数据, #include<bits/stdc++.h> using namespace std; const int maxn = 110; int n, m; vector<int> g[maxn]; int ans[maxn]; int deep = 0; void dfs(int x, int…