Advertisement
igoryanchik

iterative

Nov 27th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1.     void build(const vector<T>& a)
  2.     {
  3.         int n = a.size();
  4.         for (int i = 0; i < n; ++i)
  5.             tree[n + i].query = a[i];
  6.  
  7.         for (int i = n - 1; i > 0; --i)
  8.             tree[i].query = query(tree[2 * i].query, tree[2 * i + 1]);
  9.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement