Recursive function is playing tricks on me..

I am trying a write a function which displays the element in an AVL_tree.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct node{
    int value;
    int balance;
    node* right;
    node* left;
};


class avl_tree{
public:
    avl_tree(int);
    node *a;
    node *root;
    void insert(int);
    int balance(node *);
};

int avl_tree::balance(node* root)
{
    return max(balance(root->left), balance(root->right)) +1;
}
    
}


The problem is though i am having a hard time making the pointers point to the left and right value. Could anyone clarify why the problem occurs?
Last edited on
Topic archived. No new replies allowed.