Advertisement
Guest User

dru2

a guest
Dec 14th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include "binaryTree.h"
  2.  
  3. using namespace::std;
  4.  
  5. binaryTree::binaryTree(){
  6. root = NULL;
  7. }
  8.  
  9. binaryTree::~binaryTree(){
  10. // make_null();
  11. }
  12. bool binaryTree::add_root(Osoba *o){
  13. TreeNode *n = new TreeNode;
  14.  
  15. if(!n) return false;
  16.  
  17. n->data = o;
  18. n->left_child = NULL;
  19. n->right_child = NULL;
  20. n->parent = NULL;
  21.  
  22. root = n;
  23. return true;
  24. }
  25.  
  26. void binaryTree::print_root(){
  27. cout << endl << root->data->imie;
  28. cout<<" "<<root->data->nazwisko;
  29. cout<< ", ur. w "<<root->data->rok_urodzenia;
  30. cout<<" roku"<< endl;
  31. }
  32.  
  33. void binaryTree::print_osoba(TreeNode *n){
  34. cout << n->data->imie << " " << n->data->nazwisko << ", ur. w " << n->data->rok_urodzenia << endl;
  35. }
  36.  
  37. TreeNode* binaryTree::get_root(){
  38. return root;
  39. }
  40.  
  41. bool binaryTree::add_left_child(Osoba *o, TreeNode *n){
  42. TreeNode *p = new TreeNode;
  43. if(!p) return false;
  44. p->data = o;
  45. p->left_child = NULL;
  46. p->right_child = NULL;
  47. p->parent = n;
  48. n->left_child = p;
  49. return true;
  50. }
  51.  
  52. bool binaryTree::add_right_child(Osoba *o, TreeNode *n){
  53. TreeNode *p = new TreeNode;
  54. if(!p) return false;
  55. p->data = o;
  56. p->left_child = NULL;
  57. p->right_child = NULL;
  58. p->parent = n;
  59. n->right_child = p;
  60. return true;
  61. }
  62.  
  63. TreeNode *binaryTeee::find(string imie,string nazwisko){
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement