Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- using namespace std;
- void iteration(vector<vector<int>>& stages, int& floor, Node* node)
- {
- if (node == nullptr)
- return;
- floor++;
- iteration(stages,floor,node->left);
- stages[floor].push_back(node.value);
- iteration(stages, floor, node->right);
- stages[floor].push_back(node.value);
- floor--;
- }
- void func() {
- vector<vector<int>> result(heightMethod(head));
- iteration(result, 1, head);
- for (int i = 0; i < result.size(); i++) {
- int maxId = 0;
- for (int j = 1; j < result[i].size();j++)
- {
- if (result[i][j] > result[i][maxId])
- {
- maxId = j;
- }
- }
- cout << "Floor = " << i << " Max value = " << result[i][maxId];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement