MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / fix

Method fix

code/data-structures/avl_tree.cpp:41–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 void left_rotate(node *n) { rotate(r, l); }
40 void right_rotate(node *n) { rotate(l, r); }
41 void fix(node *n) {
42 while (n) { augment(n);
43 if (too_heavy(n)) {
44 if (left_heavy(n) && right_heavy(n->l))
45 left_rotate(n->l);
46 else if (right_heavy(n) && left_heavy(n->r))
47 right_rotate(n->r);
48 if (left_heavy(n)) right_rotate(n);
49 else left_rotate(n);
50 n = n->p; }
51 n = n->p; } }
52 inline int size() const { return sz(root); }
53 node* find(const T &item) const {
54 node *cur = root;

Callers

nothing calls this directly

Calls 1

augmentFunction · 0.85

Tested by

no test coverage detected