SHARE
TWEET

Untitled

a guest Dec 16th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void CartTree::Insert(int v, int p){
  2.     if (CartRoot == NULL){
  3.         CartRoot = new Node(v, p);
  4.         return;
  5.     }
  6.     else {
  7.         Node* currentNode = CartRoot;
  8.         Node* insertable = new Node(v, p);
  9.         while (true){
  10.             if (currentNode->Pri >= insertable->Pri){
  11.                 if (currentNode->Data <= insertable->Data){
  12.                     if (currentNode->Right == NULL){
  13.                         currentNode->Right = insertable;
  14.                     }
  15.                     else {
  16.                         currentNode = currentNode->Right;
  17.                     }
  18.                 }
  19.                 else {
  20.                     if (currentNode->Left == NULL){
  21.                         currentNode->Left = insertable;
  22.                     }
  23.                     else {
  24.                         currentNode = currentNode->Left;
  25.                     }
  26.                 }
  27.             }
  28.             else {
  29.                 Split(currentNode, insertable->Data, insertable->Left, insertable->Right);
  30.                 currentNode = insertable;
  31.             }
  32.         }
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top