Question: When constructing a segment tree, why it needs to be a full binary tree? I took some example input arrays and when made them to complete binary tree i am getting the same minimum in a range result. Then why make it a full binary tree when complete binary tree is also giving the same result.
Input array- 1, 3, 5, 7, 9, 11

Answer: 
The function setTimeout doesn't call this.update, but rather takes a copy of the update function and repeats it. Unfortunately it loses its bind to the original "this".

To work around it, you can do the following:

```
let timer_demo = {
        count: 0,
        timer: null,
        update: function() {
            this.count++;
            console.log(this.count);
            this.timer = setTimeout(this.update.bind(this), 1000);
        }
    };
timer_demo.update();

```

This makes sure that the function copy is bound to **this**.
```
var timer_demo = {
        count: 0,
        timer: null,
        update: function() {
                console.log(this);
            this.count++;
            console.log(this.count);
            this.timer = setTimeout(this.update.bind(this), 1000);
        }
 };
 timer_demo.update();

```

In setTimeout callback **this** is window object by default (in non strict mode). To pass custom this to setTimeout callback, bind is used.

For better understanding of this in javascript, read <http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/> .