Exemplo n.º 1
0
 /* Shows the structure of the binary search tree */
 void RBTree :: ShowTree( NodePtr x, int depth )
 {
    if ( x != nil ) {
       ShowTree( x->right, depth+1 ) ;
       cout << setw( depth*7 +4 ) << x->key << x->color << endl ;
       ShowTree( x->left, depth+1 ) ;
    }
 }
Exemplo n.º 2
0
/* Shows the structure of the binary search tree */
void BST :: ShowTree( NodePtr x, int depth )
{
   if ( x != NIL ) {
      ShowTree( x->right, depth+1 ) ;
      cout << setw( depth*6 +4 ) << x->key << endl ;
      ShowTree( x->left, depth+1 ) ;
   }
}
Exemplo n.º 3
0
void ShowTree(tree * tr)
{
	if(tr)
	{
		printf("Node contains (%d) %s\n",tr->repeats,tr->info);
		if (tr->left) ShowTree(tr->left);
		if (tr->right) ShowTree(tr->right);
	}
}
Exemplo n.º 4
0
void ShowTree(BinaryTree *root){
 	 if(root->lNode != NULL){
  		 ShowTree(root->lNode);
 	 }
 	 printf("%3d ",root->value);
 	 if(root->rNode != NULL){
 		 ShowTree(root->rNode);
	 }
}
Exemplo n.º 5
0
void ShowTree(STreeNode *p)
{
	if(p)
	{
		ShowTree(p->rChild);
		ShowTree(p->lChild);
		cout<<p->node;
	}
	else
	{
		count++;
	}
}
Exemplo n.º 6
0
int main(int argc, char **argv)
{
	int a[] = {8,11,6,7,19,9,22,20};
	int n = sizeof(a)/sizeof(int);
	BinaryTree *root = NULL;
 	CreateTree(&root, a, n);
	ShowTree(root);

 	int del = 20;
	DeleteTree(root,del);
	printf("\n:::\n");
 	ShowTree(root);
	DestoryTree(root);
 	return 0;
}
Exemplo n.º 7
0
int CSpiderWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (FALSE == m_wndTasks.Create (this))
		return -1;

	if (FALSE == m_wndTaskTree.Create (this))
		return -1;

	if (FALSE == m_wndSplitter.Create (AfxGetInstanceHandle (), m_hWnd, WST_HORIZONTAL))
		return -1;

	m_wndSplitter.SetWnd1 (m_wndTasks);
	m_wndSplitter.SetWnd2 (m_wndTaskTree);
	m_wndSplitter.SetRatio (_App.View_SplitterRatio ("Spider_T_TT"));

	m_bShowTree = _App.View_SpiderTree ();
	ShowTree (m_bShowTree);

	LoadPages ();

	SetTimer (1, 1000, NULL);
	
	return 0;
}
Exemplo n.º 8
0
void main()
{
	cout<<"Please enter the tree node list"<<endl;
	cin>> CNodeList;
	STreeNode Head ;
	STreeNode *p = NULL;
	length = strlen(CNodeList);
	MakeTree(Head,0);
	ShowTree(&Head);
	cout<<endl;
	cout<<"叶节点个数为 "<<count/2<<endl;
}
Exemplo n.º 9
0
int main(int argc, char * argv[])
{
	if (argc>1)
	{
		if (strcmp(argv[1],"-h")==0)
		{
			Help();
			return 0;
		}
		else 
		{
			puts("Error. Improper parameter.");
			return 0;
		}
	}
	tree *root;
	root = NULL;
	while (1)
	{
		puts("Options:\n1 - Create tree\n2 - Show tree\n3 - Count nodes on N level\n0 - Exit");
		int inp = -1;
		if (!GetInt(&inp))
			{
				puts("Input error. Try again");
				continue;
			}
		switch(inp)
		{
			case 1:
			root = CreateTree(root);
			break;
			case 2:
			ShowTree(root);
			break;
			case 3:
			CountNodes(root);
			break;
			case 0:
			TreeDel(root);
			return EXIT_SUCCESS;
			default:
			puts("Input error. Try again");
			break;			
		}
	}
	//TODO
}
Exemplo n.º 10
0
void CSpiderWnd::OnShowTree()
{
	ShowTree (m_bShowTree == FALSE);
}