Advertisement
Sanlover

Untitled

Dec 2nd, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <vector>
  2.  
  3. using namespace std;
  4.  
  5. void iteration(vector<vector<int>>& stages, int& floor, Node* node)
  6. {
  7. if (node == nullptr)
  8. return;
  9. floor++;
  10. iteration(stages,floor,node->left);
  11. stages[floor].push_back(node.value);
  12. iteration(stages, floor, node->right);
  13. stages[floor].push_back(node.value);
  14. floor--;
  15. }
  16.  
  17. void func() {
  18. vector<vector<int>> result(heightMethod(head));
  19. iteration(result, 1, head);
  20. for (int i = 0; i < result.size(); i++) {
  21. int maxId = 0;
  22. for (int j = 1; j < result[i].size();j++)
  23. {
  24. if (result[i][j] > result[i][maxId])
  25. {
  26. maxId = j;
  27. }
  28. }
  29. cout << "Floor = " << i << " Max value = " << result[i][maxId];
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement