C# binary tree operation in winform with inorder, preorder and postorder traversal

In c# for a complete binary tree operation i made a winform application like below here u can use all type of binary operation like

  • search
  • add
  • delete
  • show
  • preorder show
  • inorder show
  • postorder show

For download source code  click here

In code project i find article on binary tree. but it has not all functions i wanted so i modified it  make it a perfect winform application with new functions.
the main class for binary tree i use their classes thanks to Herbert Sauro
public class TTreeNode
{
public string name;
public double value;
public TTreeNode left, right;
// Constructor to create a single node
public TTreeNode(string name, double d)
{
this.name = name;
value = d;
left = null;
right = null;
}
}

And also i use his TBinarySTree class, i change some of functions return type and add three new functions for different type of tree traversal.

 static string s = String.Empty;
 static string si= String.Empty;
 static string sp = String.Empty;
//preorder travers
public void pree(TTreeNode node)
{ 
if (node!=null)
{
s = s + " " + node.value.ToString();
pree(node.left);
pree(node.right);
}
}
//postorder travers
public void postop(TTreeNode node)
{
if (node != null)
{
postop(node.left);
postop(node.right);
si = si + " " + node.value.ToString();
}
}
//inorder travers
public void inn(TTreeNode node)
{
if (node != null)
{
inn(node.left);
sp = sp + " " + node.value.ToString();
inn(node.right);
}
}

public void strclr() {
s = String.Empty;
si= String.Empty;
sp = String.Empty;
}

for sourcecode click here

Advertisements

About kishor datta gupta

Graduate Research Assistant at University of Memphis Software Engineer at Silicon Orchard LTD. Former Research Assistant at Lamar University Former Software Engineer at Samsung R&D Institute Bangladesh Studies Ph.D. Computer Science at University of Memphis Studied Masters of Science in Computer Sciences at Lamar University Studied BSC in CSE at Khulna University of Engineering and Technology Studied HSC (completed) at Chittagang college 04-06 Studied High school at ST. Placid's High School'04 Studied Junior Secondary School at Saint Mary's School Lives in Memphis, Tennessee
This entry was posted in C#, CPP, Winform app and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s