bool AVLTree:: insert( const Comparable & x, AVLNode* & node ) { if (x element) G //.. K K с else if (node->element right node->right new AVLNode( x, nullptr, nullptr); node->height = 1; //must be for...


C++ AVL trees help


can someone please explain to me what is this code and how it works


bool AVLTree:: insert( const Comparable & x, AVLNode* & node ) {<br>if (x < node->element)<br>G<br>//..<br>K<br>K<br>с<br>else if (node->element < x ) {<br>(E<br>Е;<br>А<br>if (node->right<br>node->right new AVLNode( x, nullptr, nullptr);<br>node->height = 1; //must be for an AVL tree<br>return true<br>}<br>else if ( insert(x, node->right ) ) {<br>node->height max( height(node),<br>nullptr) {<br>==<br>=<br>х,<br>K<br>1 height(node->right) );<br>А<br>D<br>return true<br>}<br>(E<br>} else return false; // dunlicate.<br>Problem: code must also balance the tree<br>}}<br>

Extracted text: bool AVLTree:: insert( const Comparable & x, AVLNode* & node ) { if (x < node-="">element) G //.. K K с else if (node->element < x="" )="" {="" (e="" е;="" а="" if="" (node-="">right node->right new AVLNode( x, nullptr, nullptr); node->height = 1; //must be for an AVL tree return true } else if ( insert(x, node->right ) ) { node->height max( height(node), nullptr) { == = х, K 1 height(node->right) ); А D return true } (E } else return false; // dunlicate. Problem: code must also balance the tree }}

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here