//HW6 AVL Tree
//Due: Saturday (Nov. 24) at 11:59PM
//total point: 60
#include //to use cout
#include //to use max function such as i = max(a, b);
using namespace std;
//You need to use the following node class f
...
//HW6 AVL Tree
//Due: Saturday (Nov. 24) at 11:59PM
//total point: 60
#include
//to use cout
#include //to use max function such as i = max(a, b);
using namespace std;
//You need to use the following node class for each node of the AVL tree
class node {
public:
int value;
int height;
bool is_left_child; //true if this node is the left child of its parent
node; else false;
bool is_right_child; //true if this node is the right child of its parent
node; else false;
node * parent;
node * l_child;
node * r_child;
node() {}
node(int i) {
value = i; height = 1; parent = l_child = r_child = nullptr;
is_left_child = is_right_child = false;
}
};
class avl_tree {
public:
node * root;
avl_tree() {
root = nullptr;
}
void add_node(int i);//You need to implement this.
//When there is a tie of values, continue the search toward the child
branch with smaller height.
//If both left and right child branch carry the same height, continue the
search toward the right child branch.
void in_order_traversal(node *p); //provided.
void height_adjustment(node *p, node * &action_node_pointer, int
&pattern); //You need to implement this
/*
//
You need to implement this.
This function is invoked by add_node and remove_node.
p
points to the first node that we need to check for possible height update. We
then need to check possible height update toward root.
All nodes whose heights need to be updated will be performed in this function.
When invoked, action_node_pointer = nullptr, pattern = 0.
If
no imbalance is detected, action_node_pointer remains nullptr, and pattern
[Show More]