Advertisement
amsavchenko

Untitled

May 16th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. void rootRightLeft_print() { // КПЛ обход
  2. cout << "КПЛ обход " << endl;
  3. rootRightLeft_print(root);
  4. cout << endl;
  5. }
  6.  
  7. void rootRightLeft_print(treenode<T> *node) {
  8. if (node != nullptr) {
  9. cout << node->data << " ";
  10. rootRightLeft_print(node->rightkid);
  11. rootRightLeft_print(node->leftkid);
  12. }
  13. }
  14. //////////////
  15. void leftRootRight_print() { // ЛКП обход
  16. cout << "ЛКП обход " << endl;
  17. leftRootRight_print(root);
  18. cout << endl;
  19. }
  20. void leftRootRight_print(treenode<T> *node) {
  21. if (node != nullptr) {
  22. leftRootRight_print(node->leftkid);
  23. cout << node->data << " ";
  24. leftRootRight_print(node->rightkid);
  25. }
  26. }
  27. /////////////////
  28. void print_by_levels () {
  29. cout << "Печать по строкам: " << endl;
  30.  
  31. int max_level = 0;
  32. while (pow(2, max_level) - 2 <= root->kids) max_level ++;
  33. for (int i = 0; i < max_level; i ++) {
  34. print_mentioned_level(root, i);
  35. cout << endl;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement