File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -114,14 +114,14 @@ class AVL{
114
114
head->height = 1 + max (height (head->left ), height (head->right ));
115
115
int bal = height (head->left ) - height (head->right );
116
116
if (bal>1 ){
117
- if (x > head->left -> key ){
117
+ if (height (head-> left ) >= height ( head->right ) ){
118
118
return rightRotation (head);
119
119
}else {
120
120
head->left = leftRotation (head->left );
121
121
return rightRotation (head);
122
122
}
123
123
}else if (bal < -1 ){
124
- if (x < head->right -> key ){
124
+ if (height ( head->right ) >= height (head-> left ) ){
125
125
return leftRotation (head);
126
126
}else {
127
127
head->right = rightRotation (head->right );
@@ -138,6 +138,7 @@ class AVL{
138
138
if (k < x) return searchUtil (head->right , x);
139
139
}
140
140
};
141
+ /*
141
142
int main(){
142
143
AVL<float> t;
143
144
t.insert(1.3);
@@ -153,3 +154,4 @@ int main(){
153
154
t.remove(7.9);
154
155
t.inorder();
155
156
}
157
+ */
You can’t perform that action at this time.
0 commit comments