def segment_tree_update_query(arr, tree, index, value):
    """The function updates the node in array (leaf node) and all its parent nodes till root node, complexity = O(log(n))
        input: array to be updated, tree to be updated, index of array, new value
        returns : updated array and the tree
    """
    arr[index] = value
    m = len(tree)
    i = m // 2 + index  # getting the index according to the tree from array index
    change = value - tree[i]
    while i > 0:
        tree[i] += change  # updating the current nodes
        i = i // 2  # going to update the parent
    return arr, tree