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

Method nth

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

Source from the content-addressed store, hash-verified

101 while (p && p->l == n) n = p, p = p->p;
102 return p; }
103 node* nth(int n, node *cur = NULL) const {
104 if (!cur) cur = root;
105 while (cur) {
106 if (n < sz(cur->l)) cur = cur->l;
107 else if (n > sz(cur->l))
108 n -= sz(cur->l) + 1, cur = cur->r;
109 else break;
110 } return cur; }
111 int count_less(node *cur) {
112 int sum = sz(cur->l);
113 while (cur) {

Callers 1

testFunction · 0.45

Calls

no outgoing calls

Tested by 1

testFunction · 0.36