<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Stack vergrößern?]]></title><description><![CDATA[<p>Gibt es ne möglichkeit die Größe des Stacks zu verändern, damit ich eine tiefere Rekursion hin bekomme?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/195007/stack-vergrößern</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 20:15:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195007.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 12 Oct 2007 18:06:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Stack vergrößern? on Fri, 12 Oct 2007 18:06:56 GMT]]></title><description><![CDATA[<p>Gibt es ne möglichkeit die Größe des Stacks zu verändern, damit ich eine tiefere Rekursion hin bekomme?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384007</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Fri, 12 Oct 2007 18:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Fri, 12 Oct 2007 18:17:34 GMT]]></title><description><![CDATA[<p>Bei den meisten Compilern kann man das einstellen. Beim Visual C++ gehts z.B. per /F Schalter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384015</guid><dc:creator><![CDATA[this-*gt*that]]></dc:creator><pubDate>Fri, 12 Oct 2007 18:17:34 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 06:12:57 GMT]]></title><description><![CDATA[<p>wenn das programm dann release compiliert wird, wird die stackgröße dann extra für die exe übernommen?</p>
<p>Und was ist die F Taste? Hat das konsequenzen bzw. nachteile wenn ich ihn vergrößere? Wie groß ist der Stack standartmäßig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384231</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Sat, 13 Oct 2007 06:12:57 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 07:18:27 GMT]]></title><description><![CDATA[<p>BorisDieKlinge schrieb:</p>
<blockquote>
<p>Gibt es ne möglichkeit die Größe des Stacks zu verändern, damit ich eine tiefere Rekursion hin bekomme?</p>
</blockquote>
<p>mach aus der rekursion was iteratives</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384239</guid><dc:creator><![CDATA[nogood]]></dc:creator><pubDate>Sat, 13 Oct 2007 07:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 09:34:29 GMT]]></title><description><![CDATA[<p>hatte ich schon.. aber ist zu langsam:) rekusiv ist das ding um den faktor 10-11 mal schenller (EDIT: als der iterator von std:list)</p>
<p>EDIT: Kann geschlossen werden:)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384244</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Sat, 13 Oct 2007 09:34:29 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 09:55:41 GMT]]></title><description><![CDATA[<p>Du kannst den rekursiven Algorithmus in einen iterativen umbauen. Du musst nur den Callstack in einem eigenen Stack nachbauen und anstatt Funktionsaufrufen eine Schleife. Der eigene Stack legt dann seine Daten auf dem Heap ab. Dann bleibts eigentlich genauso schnell.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384280</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384280</guid><dc:creator><![CDATA[nogood]]></dc:creator><pubDate>Sat, 13 Oct 2007 09:55:41 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 10:00:25 GMT]]></title><description><![CDATA[<p>Evtl lässt sich bei dem rekursiven Algo auch ein Parameter sparen oder so?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384282</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 13 Oct 2007 10:00:25 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 10:02:47 GMT]]></title><description><![CDATA[<p>@nogood: Aus reiner Interesse, könntest mir mal ein beispiel machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384283</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Sat, 13 Oct 2007 10:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to Stack vergrößern? on Sat, 13 Oct 2007 21:40:39 GMT]]></title><description><![CDATA[<p>BorisDieKlinge schrieb:</p>
<blockquote>
<p>@nogood: Aus reiner Interesse, könntest mir mal ein beispiel machen?</p>
</blockquote>
<p>Keine Garantie dass der Code 100% funktioniert, aber das Prinzip sollte klar sein:</p>
<pre><code class="language-cpp">int sum_tree(node const* n)
{
    if (!n)
        return 0;
    else
        return n-&gt;value + sum_tree(n-&gt;left_child) + sum_tree(n-&gt;right_child);
}

// -&gt;

int sum_tree(node const* n)
{
    std::vector&lt;std::pair&lt;node const*, int&gt; &gt; stack;
    stack.push_back(std::make_pair(n, 0));

    int accu = 0;

    while (!stack.empty())
    {
        std::pair&lt;node const*, int&gt;&amp; state = stack.back();

        switch (state.second)
        {
        case 0:
            // fresh node
            if (state.first == 0)
            {
                // null pointer -&gt; &quot;return&quot;
                stack.pop_back();
            }
            else
            {
                // add this value
                accu += state.first-&gt;value;

                // &quot;recurse&quot; left_child
                state.second = 1;
                stack.push_back(std::make_pair(state.first-&gt;left_child, 0));
            }
            break;

        case 1:
            // this node's value has already been accounted for and
            // left_child has already been visited

            // &quot;recurse&quot; right_child
            state.second = 2;
            stack.push_back(std::make_pair(state.first-&gt;right_child, 0));
            break;

        case 2:
            // this node's value has already been accounted for and
            // left_child has already been visited
            // right_child has already been visited
            stack.pop_back();
            break;
        }
    }

    return accu;
}
</code></pre>
<p>Wenn du nur einen Rekursiven Aufruf ganz am Ende der Funktion hast (&quot;tail recursion&quot;) lässt sich das ganze auch ohne Stack machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384687</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 13 Oct 2007 21:40:39 GMT</pubDate></item></channel></rss>