Maximal weight in a heap
<p>I'm trying to compute the maximal weight in a heap with this function:</p>

<pre><code>unsigned int left(unsigned int x)
{return 2*x+1;}

unsigned int right(unsigned int x)
{return 2*x+2;}

unsigned int max_way (unsigned int* feld, int x, int max_size)
{
    if (x &gt; max_size) 
        return 0;
    else 
        return feld[x] + std::max(max_way(feld, left(x), max_size), max_way(feld, right(x), max_size));
}
</code></pre>

<p>So I try it with a small example:</p>

<pre><code>unsigned int feld[] = {3,7,4,2,4,6,8,5,9,3};

std::cout &lt;&lt; max_way(feld, 0, 10);
</code></pre>

<p>The result is 134514494. That's a bit to big!</p>

<p>Any ideas?</p>
