<?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[Höchsten Knoten aus einem Binary Search Tree löschen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich implementiere gerade einen Binary Search Tree, der double Numbers in den einzelnen Knoten speichert.<br />
Nun bin ich gerade dabei eine Funktion zu schreiben, die den größen Knoten aus dem Tree löscht. Ich habe dies so versucht:</p>
<pre><code class="language-cpp">template &lt;class Item&gt;
void bst_remove_max(binary_tree_node&lt;Item&gt;*&amp; root_ptr, Item&amp; removed)
// Precondition: root_ptr is a root pointer of a non-empty binary 
// search tree.
// Postcondition: The largest item in the binary search tree has been
// removed, and root_ptr now points to the root of the new (smaller)
// binary search tree. The reference parameter, removed, has been set 
// to a copy of the removed item.
{
	binary_tree_node&lt;Item&gt; *cursor;
	cursor = root_ptr;
	if(root_ptr != NULL)
	{
		if(cursor-&gt;right() == NULL)
		{
			root_ptr = root_ptr-&gt;left();
			delete cursor;
		else 
		{
			bst_remove_max(cursor-&gt;right(), removed);
		}
	}	  
}
</code></pre>
<p>Würdet ihr das auch so machen bzw. wäre dieses funktion so korrekt? - bin mir nicht sicher ob ich da noch einen denkfehler drinnen habe.</p>
<p>lg matti</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/165754/höchsten-knoten-aus-einem-binary-search-tree-löschen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 00:45:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/165754.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Nov 2006 17:25:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Höchsten Knoten aus einem Binary Search Tree löschen on Wed, 22 Nov 2006 17:25:02 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich implementiere gerade einen Binary Search Tree, der double Numbers in den einzelnen Knoten speichert.<br />
Nun bin ich gerade dabei eine Funktion zu schreiben, die den größen Knoten aus dem Tree löscht. Ich habe dies so versucht:</p>
<pre><code class="language-cpp">template &lt;class Item&gt;
void bst_remove_max(binary_tree_node&lt;Item&gt;*&amp; root_ptr, Item&amp; removed)
// Precondition: root_ptr is a root pointer of a non-empty binary 
// search tree.
// Postcondition: The largest item in the binary search tree has been
// removed, and root_ptr now points to the root of the new (smaller)
// binary search tree. The reference parameter, removed, has been set 
// to a copy of the removed item.
{
	binary_tree_node&lt;Item&gt; *cursor;
	cursor = root_ptr;
	if(root_ptr != NULL)
	{
		if(cursor-&gt;right() == NULL)
		{
			root_ptr = root_ptr-&gt;left();
			delete cursor;
		else 
		{
			bst_remove_max(cursor-&gt;right(), removed);
		}
	}	  
}
</code></pre>
<p>Würdet ihr das auch so machen bzw. wäre dieses funktion so korrekt? - bin mir nicht sicher ob ich da noch einen denkfehler drinnen habe.</p>
<p>lg matti</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1179488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1179488</guid><dc:creator><![CDATA[mathon]]></dc:creator><pubDate>Wed, 22 Nov 2006 17:25:02 GMT</pubDate></item></channel></rss>