Answered You can hire a professional tutor to get the answer.

QUESTION

Do not have to use the fe.oval functions, only insertions will be performed.

Given the attached AVL implementation, create a red black tree. Do not have to use the fe.oval functions, only insertions will be performed.

; < T> AVL; < T>{     (left > right)         left;             right;} < T> T& left, T& right){     (left > right)         left;             right;} < T> AVLNode{    AVLNode<T>* parent, *left, *right;     height;    T data;:     AVL < T > ;    AVLNode( T& newdata = T(), AVLNode<T>* newparent = , AVLNode<T>* newleft = , AVLNode<T>* newright = ) :        data(newdata), parent(newparent), left(newleft), right(newright) {        calcHeight();    }     {         leftHeight = ;         rightHeight = ;         (left != )            leftHeight = left->height;         (right != )            rightHeight = right->height;        height = max(leftHeight, rightHeight) + ;         (parent)             parent->calcHeight();    }     {         (left != )            left->printInOrder();         << data <<<<height<< ;         (right != )            right->printInOrder();    }     ;     {         leftSize = ;         rightSize = ;         (left != )            leftSize = left->size();         (right != )            rightSize = right->size();         + leftSize + rightSize;    }    /*    int height()const{            int leftSize = -1;            int rightSize = -1;            if (left != nullptr)            leftSize = left->height();            if (right != nullptr)            rightSize = right->height();            return 1 + max(leftSize, rightSize);            }*/     {         parentDepth = ;         (parent != )            parentDepth = parent->depth();         + parentDepth;    }}; < T> AVLNode<T>::printPostOrder(){     (left != )        left->printInOrder();     (right != )        right->printInOrder();     << data << ;} < T> AVL{    AVLNode<T>* root;     size;    AVLNode<T>* recursiveCopy(AVLNode<T>* toCopy);     ;     ;     ;     ;     ;     ;:    AVL() :size(){ root = ; }        AVL( AVL<T>& rhs) :root(){ * = rhs; }     ~AVL(){ clear(); }    AVL& =( AVL<T>& rhs);     T& toFind) { find(toFind) != ; }     { root == ; }     { size; }     T& toRemove){        AVLNode<T>* item = find(toRemove);         (item != )            remove(item);    }     T&);     T&, AVLNode<T>*& point);     ;    AVLNode<T>* find( T& toFind) ;     { (!isEmpty()) remove(root); }     { root->printInOrder(); }     { root->printPostOrder(); }     ;}; < T> AVL<T>::printLevelOrder() {    <AVLNode<T>*> q;    q.push(root);     (!q.empty()){        AVLNode<T>* front = q.front();         << front->data << << front->height << ;         (front->left!=)            q.push(front->left);         (front->right)            q.push(front->right);        q.pop();    }} < T> AVL<T>::doubleCCR(AVLNode<T>*& point){    singleCR(point->right);    singleCCR(point);} < T> AVL<T>::doubleCR(AVLNode<T>*& point){    singleCCR(point->left);    singleCR(point);} < T> AVL<T>::singleCR(AVLNode<T>*& point){    AVLNode<T>* grandparent = point;    AVLNode<T>* parent = point->left;    parent->parent = grandparent->parent;    grandparent->parent = parent;    grandparent->left = parent->right;    parent->right = grandparent;     (grandparent->left != )         grandparent->left->parent = grandparent;     (parent->parent == )        root = parent;     (parent->parent->left == grandparent)        parent->parent->left = parent;            parent->parent->right = parent;    grandparent->calcHeight();    parent->calcHeight();} < T> AVL<T>::singleCCR(AVLNode<T>*& point){    AVLNode<T>* grandparent = point;    AVLNode<T>* parent = point->right;    parent->parent = grandparent->parent;    grandparent->parent = parent;    grandparent->right = parent->left;    parent->left = grandparent;     (grandparent->right != )         grandparent->right->parent = grandparent;     (parent->parent == )        root = parent;     (parent->parent->right == grandparent)        parent->parent->right = parent;            parent->parent->left = parent;    grandparent->calcHeight();    parent->calcHeight();} < T>AVLNode<T>* AVL<T>::recursiveCopy(AVLNode<T>* toCopy){     (toCopy == )         ;    AVLNode<T>* temp = AVLNode<T>(toCopy->data, , recursiveCopy(toCopy->left), recursiveCopy(toCopy->right));     (temp->left != )        temp->left->parent = temp;     (temp->right != )        temp->right->parent = temp;     temp;} < T>AVL<T>& AVL<T>::=( AVL<T>& rhs){     ( == &rhs)         *;    clear();    root = recursiveCopy(rhs.root);    size = rhs.size;     *;} < T> AVL<T>::remove(AVLNode<T>* toRemove){     (root == )        ;      (toRemove->left == && toRemove->right == ){          (toRemove->parent == ){            root = ;        }         (toRemove == toRemove->parent->left)             toRemove->parent->left = ;                     toRemove->parent->right = ;         toRemove;        size--;    }     (toRemove->right == ){          (toRemove->parent == ){            root = toRemove->left;            root->parent = ;        }         (toRemove == toRemove->parent->left){             toRemove->parent->left = toRemove->left;            toRemove->left->parent = toRemove->parent;        }        {            toRemove->parent->right = toRemove->left;            toRemove->left->parent = toRemove->parent;        }         toRemove;        size--;    }     (toRemove->left == ){          (toRemove->parent == ){            root = toRemove->right;            root->parent = ;        }         (toRemove == toRemove->parent->left){             toRemove->parent->left = toRemove->right;            toRemove->right->parent = toRemove->parent;        }        {            toRemove->parent->right = toRemove->right;            toRemove->right->parent = toRemove->parent;        }         toRemove;        size--;    }    {         AVLNode<T>* temp = toRemove->right;         (temp->left != )            temp = temp->left;        toRemove->data = temp->data;        remove(temp);    }} < T>AVLNode<T>* AVL<T>::find( T& toFind) {    AVLNode<T>* temp = root;     (temp != && temp->data != toFind){         (toFind < temp->data)            temp = temp->left;                    temp = temp->right;    }     temp;} < T> AVL<T>::insert( T& toInsert, AVLNode<T>*& point){     (point==)        point = AVLNode<T>(toInsert);     (toInsert < point->data){        insert(toInsert, point->left);        point->left->parent = point;         point->calcHeight();         (heightDiff(point) > ){            doRotation(point);        }    }    {        insert(toInsert, point->right);        point->right->parent = point;        point->calcHeight();         (heightDiff(point) > ){            doRotation(point);        }    }} < T> AVL<T>::insert( T& toInsert){    insert(toInsert, root);} < T> AVL<T>::doRotation(AVLNode<T>* point){     leftChild = ;     rightChild = ;     (point->left != )        leftChild = point->left->height;     (point->right != )        rightChild = point->right->height;     (leftChild > rightChild){         leftGC = ;         rightGC = ;         (point->left->left != )            leftGC = point->left->left->height;         (point->left->right != )            rightGC = point->left->right->height;         (leftGC > rightGC)             singleCR(point);                    doubleCR(point);    }    {         leftGC = ;         rightGC = ;         (point->right->left != )            leftGC = point->right->left->height;         (point->right->right != )            rightGC = point->right->right->height;         (leftGC > rightGC)             doubleCCR(point);                    singleCCR(point);    }}< T> AVL<T>::heightDiff(AVLNode<T>* point){     leftHeight = ;     rightHeight = ;     (point->left != )        leftHeight = point->left->height;     (point->right != )        rightHeight = point->right->height;     ((leftHeight - rightHeight));} {        AVL<> b;    srand(time());     ( i = ; i < ; i++){         val = rand() % ;        b.insert(val);    }    b.printLevelOrder();}
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question