Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

five part: AVLTree.cpp // AVLTree.h // Node.cpp // main.cpp //Node.h class AVLTree The following functions are the minimum requirements for the AVL class. You can

image text in transcribed image text in transcribed image text in transcribed five part: AVLTree.cpp // AVLTree.h // Node.cpp // main.cpp //Node.h

class AVLTree The following functions are the minimum requirements for the AVL class. You can add any function from Assignment 2 to this class. You should modify the BSTree insert function so that the tree remains balanced after each insertion Required Public Member Functions void insert(const string &): Insert an item to the binary search tree and perform rotation if necessary. int balanceFactor (Node*): Return the balance factor of a given node void printBalanceFactors(): Traverse and print the tree in inorder notation. Print the string followed by its balance factor in parentheses followed by a, and one space. void visualizeTree (const string &):Generate dotty file and visualize the tree using dotty program. Call this function before and after rotation Recommended Private Helper Functions These helper functions are recommended, but you can change them or add other helper functions if necessary. findUnbalancedNode: Find and return the closest unbalanced node (with balance factor of 2 or -2) to the inserted node. rotate: Implement four possible imbalance cases and update the parent of the given node. rotateLeft: Rotate the subtree to left at the given node and returns the new subroot. rotateRight: Rotate the subtree to right at the given node and returns the new subroot void printBalanceFactors (Node ) void visualizeTree (ofstream &,Node * Implementation of visualizeTree function void BSTree::visualizeTree (const string &outputFilename) ofstream outFS (outputFilename.c_str )) if (!outFS.is_open ()) coutleft) visualizeTree (outFS,n->left) outFSdata left->dataright) ( visualizeTree (outFs,n-right) outFSn->data " right->data "AVLTree.h" using namespace std; int menu ) int choice = 0; cout > choice; // fix buffer just in case non-numeric choice entered // also gets rid of newline character cin.clear cin.ignore (256, 'n'); return choice; int main) AVLTree tree int choicemenu ( string entry; while (choice != 3) if (choice1) cout <->

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

2 What can organisations do to improve employee utilisation?

Answered: 1 week ago