GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 17-Mar-2008, 02:12
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 545
Peter_APIIT can only hope to improve

Re: Binary Search Tree


My postorderdisplay function did not display correctly.

Here is the code :

CPP / C++ / C Code:
// -----------------------------------------------------
void PostorderDisplay(struct BST *BST)
{
	// Left->Right->Root

	printf("\n\n\t\t    Postorder Traversal Display\n");
	if (BST->root != NULL)
	{
		RecursivePostorderDisplay(BST->root);
	}
	else
	{
		exit(0);
	}
}
// -------------------------------------------------------
void RecursivePostorderDisplay(struct Tree_Node *Tree_Node)
{
	if (Tree_Node != NULL)
	{
		if (Tree_Node->leftNode != NULL)
		{
			RecursiveInorderDisplay(Tree_Node->leftNode);
		}

		if (Tree_Node->rightNode != NULL)
		{
			RecursiveInorderDisplay(Tree_Node->rightNode);
		}

		printf("\n\t\t\tValue of node : %d", Tree_Node->value);
	}
	else
	{
		exit(0);
	}
}


Anything wrong with it ?

Thanks for your help
  #12  
Old 18-Mar-2008, 03:56
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 545
Peter_APIIT can only hope to improve

Re: Binary Search Tree


How to calculate this equation in C code?

CPP / C++ / C Code:
  
2 ^ h = 8; Assume h = 3;

My friends told me that use 8 /2 = Number of division is the answers until the last number is 1.

The purpose of this function is to output a minimum height of a VST can formed when certain nodes is given by user or achieved this by API.

A billion thanks for your help.
Last edited by Peter_APIIT : 18-Mar-2008 at 04:41. Reason: Add some information
  #13  
Old 18-Mar-2008, 05:21
seprich seprich is offline
Member
 
Join Date: Jun 2007
Posts: 110
seprich has a spectacular aura aboutseprich has a spectacular aura about

Re: Binary Search Tree


Quote:
Originally Posted by Peter_APIIT
CPP / C++ / C Code:
// -------------------------------------------------------
void RecursivePostorderDisplay(struct Tree_Node *Tree_Node)
{
	if (Tree_Node != NULL)
	{
		if (Tree_Node->leftNode != NULL)
		{
			RecursiveInorderDisplay(Tree_Node->leftNode);
		}

		if (Tree_Node->rightNode != NULL)
		{
			RecursiveInorderDisplay(Tree_Node->rightNode);
		}

		printf("\n\t\t\tValue of node : %d", Tree_Node->value);
	}
	else
	{
		exit(0);
	}
}

One could assume that instead of calling "RecursiveInorderDisplay" you should call "RecursivePostorderDisplay". However please explain if your intention is something not directly obvious.

Then also the "exit(0);" seems out of place.
  #14  
Old 20-Mar-2008, 00:11
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 545
Peter_APIIT can only hope to improve

Re: Binary Search Tree


Another pair of eyes is the most useful debugger tool i have seen before.

How about calculate min height give a specific node ?
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a node from binary search tree earachefl C++ Forum 3 28-Jun-2006 08:26
can anyone help me with my tree :) bioeng_mtm C++ Forum 5 22-Apr-2006 13:50
Binary Search Tree in C++ rpg3 C++ Forum 5 02-Apr-2006 10:53
printing binary search tree nkhambal C Programming Language 2 26-Mar-2005 04:01
Search Engine Positioning 101 and 201 "How To" Tips... 000 Search Engine Optimization Forum 0 29-May-2003 11:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:22.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.