czlowiekzgon

Untitled

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