AVL Tree, deletion.

Hello, I have trouble.
It's old topic, where I found the example.
But when I made some changes - I found mistake in this program.
When you'll input:
Add new value: 1
Add new value: 2
Add new value: 3
Add new value: 4
Add new value: 5
Delete value: 1
You'll have no balance tree, how I can solve this problem?
You can find English-programm there: http://www.cplusplus.com/forum/beginner/54835/

Problem:
1
2
3
4
5
6
7
8
9
10
/////////////////////////////////////
	else if ((p->left == NULL) && (p->right == NULL))   //видалення елемента, коли і "лівий" і "правий" вказівники = 0
	{
        cout << "aas";
		d=p;
		free(d);
		p=NULL;
		cout<<"Елемент був успішно видалений\n"<<endl;
	}
    ///////////////////////////////////////////////////////////////////////////// 


Sry for my awful English and I can't write code there because I have only 9k characters.

Can someone help me?
Last edited on
Topic archived. No new replies allowed.