| 89 | return t; |
| 90 | } |
| 91 | avl *avl_tree::insert(avl *r, int v) { |
| 92 | if (r == NULL) { |
| 93 | r = new avl; |
| 94 | r->d = v; |
| 95 | r->l = NULL; |
| 96 | r->r = NULL; |
| 97 | return r; |
| 98 | } else if (v< r->d) { |
| 99 | r->l = insert(r->l, v); |
| 100 | r = balance(r); |
| 101 | } else if (v >= r->d) { |
| 102 | r->r = insert(r->r, v); |
| 103 | r = balance(r); |
| 104 | } return r; |
| 105 | } |
| 106 | void avl_tree::show(avl *p, int l) { |
| 107 | int i; |
| 108 | if (p != NULL) { |