<?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[Binary Tree Problem.]]></title><description><![CDATA[<p>Hi Leute ich versuche gerade eine Einfach Klasse für einen Binären Baum zu erstellen mein Problem ist das ich gerne Ein &quot;Wurzel&quot; benutzen möchte, jedoch nicht weiß wie ich das machen soll, außerdem wäre ich dankbar für Vorschläge um meine einfeugen funktione zu realisieren.</p>
<pre><code class="language-cpp">// BaumKlasse.cpp : Defines the entry point for the console application.
//

#include &quot;stdafx.h&quot;
#include &lt;stdlib.h&gt;

class BaumElement {
public:	
	BaumElement *rechts;							//Pointer auf das jeweils recht und linke Element	
	BaumElement *links;
	int index;										//Indexierungswert um den Baum zu ordnen
	BaumElement ();									//Std. construktor der ein Element erzeugt das in keine Richtung zeigt mit dem Indexwert 0.
	~BaumElement ();
	void einfuegen (BaumElement *BElement, int x);			//Eine Funktion um  ein neues Baum Element in den Baum einzufügen.
	BaumElement (int wert);
};

BaumElement::BaumElement(int wert)
{
	index = wert;
};

BaumElement::BaumElement() {
	rechts = NULL;
	links  = NULL;
	index = 0;
};

//WuzelKlasse sie stellt die Wurzel für den Baum dar und soll die größe speichern, falls der Baum NULL ist soll hier eine das neue Element zur Wurzel werden

class Wurzel {
public:
	BaumElement *root;
	int size;
	Wurzel ();
	~Wurzel();
};

Wurzel::Wurzel() {
	root-&gt;links=NULL;
	root-&gt;rechts=NULL;
	size = 0;
};

void BaumElement::einfuegen(BaumElement *BElement, int x) {
	if (BElement == NULL) {
			BElement = new BaumElement(x);
	};

}

int main (void) {
	return 0;
}
</code></pre>
<p>Gruß Philipp</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/209328/binary-tree-problem</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 14:36:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/209328.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Mar 2008 11:58:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Binary Tree Problem. on Sat, 29 Mar 2008 11:58:37 GMT]]></title><description><![CDATA[<p>Hi Leute ich versuche gerade eine Einfach Klasse für einen Binären Baum zu erstellen mein Problem ist das ich gerne Ein &quot;Wurzel&quot; benutzen möchte, jedoch nicht weiß wie ich das machen soll, außerdem wäre ich dankbar für Vorschläge um meine einfeugen funktione zu realisieren.</p>
<pre><code class="language-cpp">// BaumKlasse.cpp : Defines the entry point for the console application.
//

#include &quot;stdafx.h&quot;
#include &lt;stdlib.h&gt;

class BaumElement {
public:	
	BaumElement *rechts;							//Pointer auf das jeweils recht und linke Element	
	BaumElement *links;
	int index;										//Indexierungswert um den Baum zu ordnen
	BaumElement ();									//Std. construktor der ein Element erzeugt das in keine Richtung zeigt mit dem Indexwert 0.
	~BaumElement ();
	void einfuegen (BaumElement *BElement, int x);			//Eine Funktion um  ein neues Baum Element in den Baum einzufügen.
	BaumElement (int wert);
};

BaumElement::BaumElement(int wert)
{
	index = wert;
};

BaumElement::BaumElement() {
	rechts = NULL;
	links  = NULL;
	index = 0;
};

//WuzelKlasse sie stellt die Wurzel für den Baum dar und soll die größe speichern, falls der Baum NULL ist soll hier eine das neue Element zur Wurzel werden

class Wurzel {
public:
	BaumElement *root;
	int size;
	Wurzel ();
	~Wurzel();
};

Wurzel::Wurzel() {
	root-&gt;links=NULL;
	root-&gt;rechts=NULL;
	size = 0;
};

void BaumElement::einfuegen(BaumElement *BElement, int x) {
	if (BElement == NULL) {
			BElement = new BaumElement(x);
	};

}

int main (void) {
	return 0;
}
</code></pre>
<p>Gruß Philipp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482603</guid><dc:creator><![CDATA[Graf]]></dc:creator><pubDate>Sat, 29 Mar 2008 11:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to Binary Tree Problem. on Sat, 29 Mar 2008 21:34:54 GMT]]></title><description><![CDATA[<p>Eigentlich brauchst Du eine Klasse Baum, die die Baumelemente (Knoten) verwaltet.<br />
Die Wurzel ist ebenso ein Knoten, jedoch hat sie keine Vorgänger.</p>
<pre><code class="language-cpp">class Node // Knoten
{
public:
    Node(int val) : left(NULL), right(NULL), value(val) {}

    // Getter und Setter etc.
private:
    Node* left;
    Node* right;
    int value;
};

class Tree
{
public:
    Tree() : root(NULL) {}
    // Methoden zum einfügen,
    // ausgeben, suchen etc.

private:
    Node* root;
};
</code></pre>
<p>Vielleicht reicht Dir das erstmal als Ansatz...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482894</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Sat, 29 Mar 2008 21:34:54 GMT</pubDate></item><item><title><![CDATA[Reply to Binary Tree Problem. on Sat, 29 Mar 2008 21:58:14 GMT]]></title><description><![CDATA[<p>Hi Philipp,</p>
<p>wegen des Einfügens:</p>
<pre><code class="language-cpp">void Tree::insert(int value){
	Node** current = &amp;root;
	while(*current != 0){
		if((*current)-&gt;value&gt;value)
			current = &amp;(*current)-&gt;left;
		else
			current = &amp;(*current)-&gt;right; 
	};
	*current = new Node(value);
}
</code></pre>
<p>Ich hoffe das hilft dir weiter...</p>
<p>Gruß,<br />
Spille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482915</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 29 Mar 2008 21:58:14 GMT</pubDate></item></channel></rss>