title: What is the need to finish a segment tree with zeroes where elements are empty?
body: <p>I work with segment trees now. It is known that segment trees has 2^n leaves. Let us imagine an array <code>data</code> that consists of 5 elements [1, 2, 3, 4, 5] and is basic for a segment tree. We also have an array <code>tree_data</code> containing the tree itself (the right half of <code>tree_data</code> contains elements of <code>data</code>). It would be logical to allocate 5 elements in <code>tree_data</code> to contain elements from <code>data</code>, but it is stated that we have to fill the other three elements with zeroes to make the right half of <code>tree_data</code> consist of 8 elements and contain [1, 2, 3, 4, 5, 0, 0, 0].
  <a href="https://i.stack.imgur.com/5kgjO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5kgjO.png" alt="segment tree from an example"></a>
  Why should we do this instead of saving memory by filling the array with only five elements? Why do we need nodes 7, 14, 15 (see image) to create a segment tree?</p>