Advertisement
czlowiekzgon

Untitled

Dec 7th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.39 KB | None | 0 0
  1. //SDIZO I1 222A LAB04
  2. //Paweł Patyk
  3. //pp41473@zut.edu.pl
  4.  
  5. #include "pch.h"
  6. #include <iostream>
  7. #include <sstream>
  8. #include <string>
  9. #include <cstdlib>
  10. #include <ctime>
  11. #include <fstream>
  12. #include <math.h>
  13. using namespace std;
  14.  
  15.  
  16. class Element {
  17. private:
  18. int key;
  19. int balance;
  20. Element *ptrLeft;
  21. Element *ptrRight;
  22. char tab[10];
  23. public:
  24. Element();
  25. Element(int keyVal);
  26. ~Element();
  27. int getKey();
  28. int getBalance();
  29. Element * getPtrLeft();
  30. Element * getPtrRight();
  31. char * getTab();
  32.  
  33. void setPtrLeft(int liczba);
  34. void setPtrLeft(Element *ptr);
  35. void setPtrRight(int liczba);
  36. void setPtrRight(Element *ptr);
  37. void increaseBalance();
  38. void reduceBalance();
  39.  
  40.  
  41. };
  42.  
  43. Element::Element() {
  44.  
  45. }
  46.  
  47. Element::Element(int keyVal) {
  48. key = keyVal;
  49. sprintf_s(tab, "%d", keyVal);
  50. balance = 0;
  51. }
  52.  
  53.  
  54. Element ::~Element() {
  55.  
  56. }
  57.  
  58. int Element::getKey() {
  59. return this->key;
  60. }
  61.  
  62. int Element::getBalance() {
  63. return this->balance;
  64. }
  65.  
  66. Element * Element::getPtrLeft() {
  67. return this->ptrLeft;
  68. }
  69.  
  70. Element * Element::getPtrRight() {
  71. return this->ptrRight;
  72. }
  73.  
  74. char * Element::getTab() {
  75. return tab;
  76. }
  77.  
  78. void Element::setPtrLeft(int liczba) {
  79. ptrLeft = new Element(liczba);
  80. }
  81.  
  82. void Element::setPtrRight(int liczba) {
  83. ptrRight = new Element(liczba);
  84. }
  85.  
  86.  
  87. void Element::setPtrLeft(Element * ptr) {
  88. ptrLeft = ptr;
  89. }
  90.  
  91. void Element::setPtrRight(Element * ptr) {
  92. ptrRight = ptr;
  93. }
  94.  
  95. void Element::increaseBalance() {
  96. balance++;
  97. }
  98.  
  99. void Element::reduceBalance() {
  100. balance--;
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107. class Tree {
  108. private:
  109. Element * root = nullptr;
  110. int numberElements;
  111. public:
  112. Tree();
  113. Tree(int i);
  114. void setRoot(Element * ptr);
  115. void add(int keyVal);
  116. void addMany(int num);
  117. bool find(int key_val, bool kom = true);
  118. void remove(int key_val);
  119.  
  120. void rotateRight(Element * ptrGrand,Element * ptrPar,Element * ptrChild);
  121. void rotateLeft(Element * ptrGrand, Element * ptrPar, Element * ptrChild);
  122. void showPreorder();
  123. void showPreorder(Element * ptr, int &i);
  124. void showInorder();
  125. void showInorder(Element * ptr, int &i);
  126. void showPostorder();
  127. void showPostorder(Element * ptr, int &i);
  128. void showNumberElements();
  129. };
  130.  
  131. Tree::Tree() {
  132.  
  133. }
  134.  
  135. void Tree::setRoot(Element * ptr) {
  136. root = ptr;
  137. }
  138.  
  139.  
  140.  
  141. void Tree::showPreorder(Element * ptr, int &i) {
  142. if (ptr == nullptr) {
  143. return;
  144. }
  145. else {
  146. i++;
  147. cout << ptr->getKey() << endl;
  148. showPreorder(ptr->getPtrLeft(), i);
  149. showPreorder(ptr->getPtrRight(), i);
  150. }
  151. }
  152.  
  153. void Tree::showPreorder() {
  154. int i = 0;
  155. if (root == nullptr) {
  156. cout << "nie mozna wyswietlic korzen jest pusty" << endl;
  157. }
  158. else {
  159. showPreorder(root, i);
  160. cout << "liczba odwiedzanych wezlow : " << i << endl;
  161. }
  162. }
  163.  
  164. void Tree::showInorder(Element * ptr, int &i) {
  165. if (ptr == nullptr) {
  166. return;
  167. }
  168. else {
  169. i++;
  170. showInorder(ptr->getPtrLeft(), i);
  171. cout << ptr->getKey() << endl;
  172. showInorder(ptr->getPtrRight(), i);
  173. }
  174. }
  175.  
  176. void Tree::showInorder() {
  177. int i = 0;
  178.  
  179. if (root == nullptr) {
  180. cout << "nie mozna wyswietlic korzen jest pusty" << endl;
  181. }
  182. else {
  183. showInorder(root, i);
  184. cout << "liczba odwiedzanych wezlow : " << i << endl;
  185. }
  186. }
  187.  
  188.  
  189.  
  190. void Tree::showPostorder(Element * ptr, int &i) {
  191. if (ptr == nullptr) {
  192. return;
  193. }
  194. else {
  195. i++;
  196. showPostorder(ptr->getPtrLeft(), i);
  197. showPostorder(ptr->getPtrRight(), i);
  198. cout << ptr->getKey() << endl;
  199. }
  200. }
  201.  
  202.  
  203. void Tree::showPostorder() {
  204. int i = 0;
  205. if (root == nullptr) {
  206. cout << "nie mozna wyswietlic korzen jest pusty" << endl;
  207. }
  208. else {
  209. showPostorder(root, i);
  210. cout << "liczba odwiedzanych wezlow : " << i << endl;
  211. }
  212. }
  213.  
  214.  
  215. void Tree::showNumberElements() {
  216. cout << "Liczba elementow : " << numberElements << endl;
  217. }
  218.  
  219.  
  220. bool Tree::find(int key_val, bool kom) {
  221. Element * supPtr = root;
  222. if (root == nullptr) {
  223. if (kom == true) {
  224. cout << "korzen jest pusty" << endl;
  225. }
  226. return false;
  227. }
  228. if (supPtr->getKey() == key_val) {
  229. if (kom == true) {
  230. cout << "istnieje element z podanym kluczem " << endl;
  231. }
  232. return true;
  233. }
  234. else if (supPtr->getKey() > key_val) {
  235. supPtr = supPtr->getPtrLeft();
  236. }
  237. else if (supPtr->getKey() < key_val) {
  238. supPtr = supPtr->getPtrRight();
  239. }
  240.  
  241. while (supPtr != nullptr) {
  242. if (supPtr->getKey() == key_val) {
  243. if (kom == true) {
  244. cout << "istnieje element z podanym kluczem " << endl;
  245. }
  246. return true;
  247. }
  248. else if (supPtr->getKey() > key_val) {
  249. supPtr = supPtr->getPtrLeft();
  250. }
  251. else if (supPtr->getKey() < key_val) {
  252. supPtr = supPtr->getPtrRight();
  253. }
  254. }
  255. if (supPtr == nullptr) {
  256. if (kom == true) {
  257. cout << "nie ma elementu o podanym kluczu " << endl;
  258. }
  259. return false;
  260. }
  261. }
  262.  
  263. void Tree::rotateRight(Element * ptrGrand, Element * ptrPar, Element * ptrChild) {
  264. if (ptrGrand != nullptr) {
  265. if (ptrGrand->getPtrRight() == ptrPar) {
  266. ptrGrand->setPtrRight(ptrChild);
  267. }
  268. else{
  269. ptrGrand->setPtrLeft(ptrChild);
  270. }
  271. }
  272. else {
  273. root = ptrChild;
  274. }
  275. Element *ptrSup = ptrChild->getPtrRight();
  276. ptrChild->setPtrLeft(ptrPar);
  277. ptrPar->setPtrRight(ptrSup);
  278.  
  279.  
  280. }
  281.  
  282.  
  283. void Tree::rotateLeft(Element * ptrGrand, Element * ptrPar, Element * ptrChild) {
  284. if (ptrGrand != nullptr) {
  285. if (ptrGrand->getPtrRight() == ptrPar) {
  286. ptrGrand->setPtrRight(ptrChild);
  287. }
  288. else {
  289. ptrGrand->setPtrLeft(ptrChild);
  290. }
  291. }
  292. else {
  293. root = ptrChild;
  294. }
  295. Element *ptrSup = ptrChild->getPtrLeft();
  296. ptrChild->setPtrRight(ptrPar);
  297. ptrPar->setPtrLeft(ptrSup);
  298.  
  299.  
  300. }
  301.  
  302. void Tree::add(int keyVal) {
  303.  
  304. bool czy_sie_powtarza = find(keyVal, false);
  305. if (czy_sie_powtarza == true) {
  306. cout << "nie mozna dodac obikektu poniewaz istnieje juz jeden z takim kluczem" << endl;
  307. return;
  308. }
  309.  
  310. if (root == nullptr) {
  311. root = new Element(keyVal);
  312. numberElements++;
  313. return;
  314. }
  315.  
  316.  
  317.  
  318. Element * supPtr = root;
  319. int sizeArray = log2(numberElements) + 1;
  320. Element **tabPtr = new Element *[sizeArray];
  321. for (int i = 0; i < sizeArray; i++) {
  322. tabPtr[i] = nullptr;
  323. }
  324.  
  325.  
  326.  
  327. for (int i = 0; i < sizeArray; i++) {
  328. tabPtr[i] = supPtr;
  329. if (supPtr->getKey() > keyVal && supPtr->getPtrLeft() != nullptr) {
  330. supPtr->reduceBalance();
  331. supPtr = supPtr->getPtrLeft();
  332. }
  333. else if (supPtr->getKey() < keyVal && supPtr->getPtrRight() != nullptr) {
  334. supPtr->increaseBalance();
  335. supPtr = supPtr->getPtrRight();
  336. }
  337. else if (supPtr->getKey() > keyVal && supPtr->getPtrLeft() == nullptr) {
  338.  
  339. supPtr->reduceBalance();
  340.  
  341. supPtr->setPtrLeft(keyVal);
  342. break;
  343. }
  344. else if (supPtr->getKey() < keyVal && supPtr->getPtrRight() == nullptr) {
  345.  
  346. supPtr->increaseBalance();
  347. supPtr->setPtrRight(keyVal);
  348. break;
  349. }
  350. }
  351.  
  352.  
  353.  
  354.  
  355. numberElements++;
  356. for (int i = 0; i < sizeArray; i++) {
  357. if (tabPtr[i] == nullptr) {
  358. break;
  359. }
  360. cout << tabPtr[i]->getBalance() << " " << tabPtr[i]->getKey() << endl;
  361. }
  362. cout << endl;
  363. }
  364.  
  365.  
  366.  
  367.  
  368. int main()
  369. {
  370.  
  371.  
  372. Tree tree;
  373. //tree.showNumberElements();
  374. tree.add(10);
  375. tree.add(5);
  376.  
  377. tree.add(15);
  378. tree.add(6);
  379. tree.add(11);
  380. //tree.add(13);
  381. //tree.add(18);
  382.  
  383.  
  384.  
  385.  
  386. //srand(time(NULL));
  387.  
  388. //int k1, k2, k3, k4, number;
  389. //fstream infile;
  390. //infile.open("inlab03.txt");
  391. //if (infile.good() == false) {
  392. // cout << "blad" << endl;
  393. //}
  394. //infile >> number;
  395. //infile >> k1;
  396. //infile >> k2;
  397. //infile >> k3;
  398. //infile >> k4;
  399.  
  400. //infile.close();
  401.  
  402.  
  403. }
  404.  
  405.  
  406.  
  407. //class Element {
  408. //
  409. //private:
  410. // int key;
  411. // Element * ptr_left = nullptr;
  412. // Element * ptr_right = nullptr;
  413. // char tab[10];
  414. // int balance;
  415. //public:
  416. // Element();
  417. // Element(int key_val);
  418. // int get_key();
  419. // Element * get_ptr_left();
  420. // Element * get_ptr_right();
  421. // void set_ptr_left(int liczba);
  422. // void set_ptr_right(int liczba);
  423. // void set_ptr_left(Element * ptr);
  424. // void set_ptr_right(Element * ptr);
  425. // char * show_tab();
  426. //
  427. //};
  428. //Element::Element() {
  429. //
  430. //}
  431. //
  432. //Element::Element(int key_val) {
  433. // key = key_val;
  434. // sprintf_s(tab, "%d", key_val);
  435. //}
  436. //
  437. //
  438. //
  439. //int Element::get_key() {
  440. // return key;
  441. //}
  442. //
  443. //Element * Element::get_ptr_left() {
  444. // return ptr_left;
  445. //}
  446. //
  447. //Element * Element::get_ptr_right() {
  448. // return ptr_right;
  449. //}
  450. //
  451. //void Element::set_ptr_left(int liczba) {
  452. // ptr_left = new Element(liczba);
  453. //}
  454. //
  455. //void Element::set_ptr_right(int liczba) {
  456. // ptr_right = new Element(liczba);
  457. //}
  458. //
  459. //
  460. //void Element::set_ptr_left(Element * ptr) {
  461. // ptr_left = ptr;
  462. //}
  463. //
  464. //void Element::set_ptr_right(Element * ptr) {
  465. // ptr_right = ptr;
  466. //}
  467. //
  468. //
  469. //char * Element::show_tab() {
  470. // return tab;
  471. //}
  472. //
  473. //class Tree {
  474. //private:
  475. // Element * root = nullptr;
  476. //
  477. //public:
  478. // Tree();
  479. // Tree(int i);
  480. // void set_root(Element * ptr);
  481. // void add(int key_val);
  482. // void add_many(int num);
  483. // bool find(int key_val, bool kom = true);
  484. // void remove(int key_val);
  485. // void show_pre_order();
  486. // void show_pre_order(Element * ptr, int &i);
  487. // void show_in_order();
  488. // void show_in_order(Element * ptr, int &i);
  489. // void show_post_order();
  490. // void show_post_order(Element * ptr, int &i);
  491. //};
  492. //
  493. //
  494. //
  495. //
  496. //
  497. //
  498. //
  499. //Tree::Tree() {
  500. //
  501. //}
  502. //
  503. //void Tree::set_root(Element * ptr) {
  504. // root = ptr;
  505. //}
  506. //
  507. //bool Tree::find(int key_val, bool kom) {
  508. // Element * sup_ptr = root;
  509. // if (root == nullptr) {
  510. // if (kom == true) {
  511. // cout << "korzen jest pusty" << endl;
  512. //
  513. // }
  514. // return false;
  515. // }
  516. // if (sup_ptr->get_key() == key_val) {
  517. // if (kom == true) {
  518. // cout << "istnieje element z podanym kluczem " << endl;
  519. //
  520. // }
  521. // return true;
  522. // }
  523. // else if (sup_ptr->get_key() > key_val) {
  524. // sup_ptr = sup_ptr->get_ptr_left();
  525. // }
  526. // else if (sup_ptr->get_key() < key_val) {
  527. // sup_ptr = sup_ptr->get_ptr_right();
  528. // }
  529. //
  530. // while (sup_ptr != nullptr) {
  531. // if (sup_ptr->get_key() == key_val) {
  532. // if (kom == true) {
  533. // cout << "istnieje element z podanym kluczem " << endl;
  534. // }
  535. // return true;
  536. // }
  537. // else if (sup_ptr->get_key() > key_val) {
  538. // sup_ptr = sup_ptr->get_ptr_left();
  539. // }
  540. // else if (sup_ptr->get_key() < key_val) {
  541. // sup_ptr = sup_ptr->get_ptr_right();
  542. // }
  543. // }
  544. // if (sup_ptr == nullptr) {
  545. // if (kom == true) {
  546. // cout << "nie ma elementu o podanym kluczu " << endl;
  547. //
  548. // }
  549. // return false;
  550. // }
  551. //}
  552. //
  553. //
  554. //void Tree::add(int key_val) {
  555. //
  556. // if (root == nullptr) {
  557. // root = new Element(key_val);
  558. // return;
  559. //
  560. // }
  561. //
  562. // bool czy_sie_powtarza = find(key_val, false);
  563. // if (czy_sie_powtarza == true) {
  564. // cout << "nie mozna dodac obikektu poniewaz istnieje juz jeden z takim kluczem" << endl;
  565. // return;
  566. // }
  567. //
  568. // Element * sup_ptr = root;
  569. //
  570. //
  571. // while ((sup_ptr->get_key() > key_val && sup_ptr->get_ptr_left() != nullptr) || (sup_ptr->get_key() < key_val && sup_ptr->get_ptr_right() != nullptr)) {
  572. // if (sup_ptr->get_key() > key_val) {
  573. // sup_ptr = sup_ptr->get_ptr_left();
  574. // }
  575. // else if (sup_ptr->get_key() < key_val) {
  576. // sup_ptr = sup_ptr->get_ptr_right();
  577. // }
  578. //
  579. // }
  580. // if (sup_ptr->get_key() > key_val) {
  581. // sup_ptr->set_ptr_left(key_val);
  582. // }
  583. // else if (sup_ptr->get_key() < key_val) {
  584. // sup_ptr->set_ptr_right(key_val);
  585. // }
  586. //
  587. //}
  588. //
  589. //void Tree::add_many(int num) {
  590. // for (int i = 0; i < num; i++) {
  591. // int key_val = (rand() % 20000) - 10000;
  592. // while (find(key_val, false) == true) {
  593. // key_val = (rand() % 20000) - 10000;
  594. // }
  595. // add(key_val);
  596. // }
  597. //
  598. //}
  599. //
  600. //
  601. //
  602. //void Tree::show_pre_order(Element * ptr, int &i) {
  603. // if (ptr == nullptr) {
  604. // return;
  605. // }
  606. // else {
  607. // i++;
  608. // cout << ptr->get_key() << endl;
  609. // show_pre_order(ptr->get_ptr_left(), i);
  610. // show_pre_order(ptr->get_ptr_right(), i);
  611. // }
  612. //}
  613. //
  614. //void Tree::show_pre_order() {
  615. // int i = 0;
  616. // if (root == nullptr) {
  617. // cout << "nie mozna wyswietlic korzen jest pusty" << endl;
  618. // }
  619. // else {
  620. // show_pre_order(root, i);
  621. // cout << "liczba odwiedzanych wezlow : " << i << endl;
  622. // }
  623. //}
  624. //
  625. //void Tree::show_in_order(Element * ptr, int &i) {
  626. // if (ptr == nullptr) {
  627. // return;
  628. // }
  629. // else {
  630. // i++;
  631. // show_in_order(ptr->get_ptr_left(), i);
  632. // cout << ptr->get_key() << endl;
  633. // show_in_order(ptr->get_ptr_right(), i);
  634. // }
  635. //}
  636. //
  637. //void Tree::show_in_order() {
  638. // int i = 0;
  639. //
  640. // if (root == nullptr) {
  641. // cout << "nie mozna wyswietlic korzen jest pusty" << endl;
  642. // }
  643. // else {
  644. // show_in_order(root, i);
  645. // cout << "liczba odwiedzanych wezlow : " << i << endl;
  646. // }
  647. //}
  648. //
  649. //
  650. //
  651. //void Tree::show_post_order(Element * ptr, int &i) {
  652. // if (ptr == nullptr) {
  653. // return;
  654. // }
  655. // else {
  656. // i++;
  657. // show_post_order(ptr->get_ptr_left(), i);
  658. // show_post_order(ptr->get_ptr_right(), i);
  659. // cout << ptr->get_key() << endl;
  660. // }
  661. //}
  662. //
  663. //
  664. //void Tree::show_post_order() {
  665. // int i = 0;
  666. // if (root == nullptr) {
  667. // cout << "nie mozna wyswietlic korzen jest pusty" << endl;
  668. // }
  669. // else {
  670. // show_post_order(root, i);
  671. // cout << "liczba odwiedzanych wezlow : " << i << endl;
  672. // }
  673. //}
  674. //
  675. //
  676. //void Tree::remove(int key_val) {
  677. // Element * ptr = root;
  678. // Element * par_ptr = nullptr;
  679. // if (root == nullptr) {
  680. // cout << " nie mozna usunac wezla ,korzen jest pusty" << endl;
  681. // return;
  682. // }
  683. // while (ptr != nullptr) {
  684. //
  685. // if (ptr->get_key() == key_val) {
  686. //
  687. // if (ptr->get_ptr_left() == nullptr && ptr->get_ptr_right() == nullptr) {
  688. // if (par_ptr->get_ptr_left() == ptr) {
  689. // if (root == ptr) {
  690. // delete ptr;
  691. // root = nullptr;
  692. // }
  693. // delete ptr;
  694. // par_ptr->set_ptr_left(nullptr);
  695. // return;
  696. // }
  697. // else {
  698. // if (root == ptr) {
  699. // delete ptr;
  700. // root = nullptr;
  701. // }
  702. // delete ptr;
  703. // par_ptr->set_ptr_right(nullptr);
  704. // return;
  705. // }
  706. // }
  707. //
  708. // else if (ptr->get_ptr_left() == nullptr && ptr->get_ptr_right() != nullptr) {
  709. // if (par_ptr->get_ptr_left() == ptr) {
  710. //
  711. // par_ptr->set_ptr_left(ptr->get_ptr_right());
  712. // delete ptr;
  713. // return;
  714. // }
  715. // else {
  716. //
  717. // par_ptr->set_ptr_right(ptr->get_ptr_right());
  718. // delete ptr;
  719. // return;
  720. // }
  721. // }
  722. // else if ((ptr->get_ptr_left() != nullptr && ptr->get_ptr_right() == nullptr)) {
  723. // if (ptr == root) {
  724. // Element * sup_ptr = ptr->get_ptr_left();
  725. // delete root;
  726. // root = sup_ptr;
  727. // return;
  728. // }
  729. // if (par_ptr->get_ptr_left() == ptr) {
  730. //
  731. // par_ptr->set_ptr_left(ptr->get_ptr_left());
  732. // delete ptr;
  733. // return;
  734. // }
  735. // else {
  736. //
  737. // par_ptr->set_ptr_right(ptr->get_ptr_left());
  738. // delete ptr;
  739. // return;
  740. // }
  741. // }
  742. // else if ((ptr->get_ptr_left() != nullptr && ptr->get_ptr_right() != nullptr)) {
  743. //
  744. //
  745. //
  746. // Element *succes_ptr = ptr->get_ptr_right();
  747. // Element * par_succes_ptr = nullptr;
  748. // while (succes_ptr->get_ptr_left() != nullptr) {
  749. // par_succes_ptr = succes_ptr;
  750. // succes_ptr = succes_ptr->get_ptr_left();
  751. // }
  752. // if (succes_ptr->get_ptr_right() == nullptr) {
  753. // if (root == ptr && (ptr->get_ptr_right() == succes_ptr)) {
  754. //
  755. // }
  756. // else {
  757. // if (par_succes_ptr == nullptr) {
  758. // succes_ptr->set_ptr_left(ptr->get_ptr_left());
  759. // }
  760. // else
  761. // {
  762. // par_succes_ptr->set_ptr_left(nullptr);
  763. // }
  764. //
  765. // }
  766. //
  767. // }
  768. // else {
  769. // if (root == ptr && (ptr->get_ptr_right() == succes_ptr)) {
  770. //
  771. // }
  772. // else
  773. // {
  774. // if (par_succes_ptr == nullptr) {
  775. // succes_ptr->set_ptr_left(ptr->get_ptr_left());
  776. // }
  777. // else
  778. // {
  779. // par_succes_ptr->set_ptr_left(succes_ptr->get_ptr_right());
  780. // }
  781. //
  782. // }
  783. //
  784. // }
  785. //
  786. // succes_ptr->set_ptr_left(ptr->get_ptr_left());
  787. // if (ptr == root && (ptr->get_ptr_right() == succes_ptr)) {
  788. //
  789. // }
  790. // else {
  791. // if (par_succes_ptr == nullptr)
  792. // {
  793. // }
  794. // else
  795. // {
  796. // succes_ptr->set_ptr_right(ptr->get_ptr_right());
  797. // }
  798. //
  799. // }
  800. // if (ptr == root) {
  801. // delete root;
  802. // root = succes_ptr;
  803. // return;
  804. // }
  805. //
  806. // if (par_ptr->get_ptr_left() == ptr) {
  807. // par_ptr->set_ptr_left(succes_ptr);
  808. // delete ptr;
  809. // return;
  810. // }
  811. // else {
  812. // par_ptr->set_ptr_right(succes_ptr);
  813. // delete ptr;
  814. // return;
  815. // }
  816. //
  817. //
  818. // }
  819. //
  820. //
  821. // }
  822. // else if (ptr->get_key() > key_val) {
  823. // par_ptr = ptr;
  824. // ptr = ptr->get_ptr_left();
  825. // }
  826. // else {
  827. // par_ptr = ptr;
  828. // ptr = ptr->get_ptr_right();
  829. // }
  830. // }
  831. // cout << "nie mozna usunac wezla poniewaz nie istnieje " << endl;
  832. // return;
  833. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement