Index out of range exception was unhandled in c# (creating binary search tree with two traversals)
<p>I can't find the problem with this code,it says that: Index was outside the bounds of the array in this section:</p>

<pre><code>Node node = new Node(postorder[iterator]);
</code></pre>

<p>Here is the code:</p>

<pre><code>public Node reQ_buildTreeUtil(int[] inorder, int[] postorder, int start ,int end, int iterator)
{
    //base case 
    if (start &gt; end)
        return null;

    Node node = new Node(postorder[iterator]);
    iterator--;

    if (start == end)
        return node;

    int index_in_Inorder = index_search(inorder, start,node.value);

    node.right = reQ_buildTreeUtil(inorder, postorder, index_in_Inorder + 1, end, iterator);
    node.left = reQ_buildTreeUtil(inorder, postorder, start ,index_in_Inorder - 1, iterator);

    return node;
}

public Node buildTree(int[] inorder, int[] postorder)
{
    int n = vinorder.Length;
    int iterator = n - 1;

    return reQ_buildTreeUtil(inorder, postorder, 0, n - 1, iterator);
}

int index_search(int[] array,int start, int x)
{
    int i;
    for ( i = start;i &lt; array.Length; i++)
    {
        if (array[i] == x)
            break;
    }
    return i;
}
</code></pre>