|
// TestLibTree.cpp : Defines the entry point for the console application.
//
// uncomment the areas to see how it works.
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
CTree<int> objCTree ;
CNode<int> *pNode = NULL;
CListNode<int> *pListNode = NULL;
int *i= new int;
int j=0;
*i=15;
objCTree.Insert(*i) ;
*i=10;
objCTree.Insert(*i) ;
*i=20 ;
objCTree.Insert(*i) ;
*i=25 ;
objCTree.Insert(*i) ;
*i=18 ;
objCTree.Insert(*i) ;
*i=13 ;
objCTree.Insert(*i) ;
*i=8 ;
objCTree.Insert(*i) ;
*i=4 ;
objCTree.Insert(*i) ;
*i=3 ;
objCTree.Insert(*i) ;
*i=5 ;
objCTree.Insert(*i) ;
*i=14 ;
objCTree.Insert(*i) ;
*i=17 ;
objCTree.Insert(*i) ;
*i=19 ;
objCTree.Insert(*i) ;
//deletion
/*
*i=5 ;
objCTree.Search(*i,&pNode) ;
if(!pNode) {
cout<<"\nNot Found\n"<<endl;
}
objCTree.Delete(pNode) ;
*i=3 ;
objCTree.Delete(*i);
*/
//minimum & maximum
/*
*i=15 ;
objCTree.Maximum(*i,j);
objCTree.Minimum(*i,j);
*/
/*
// Successor & Predecessor
*i=15 ;
objCTree.Successor(*i,j);
objCTree.Predecessor(*i,j);
*i=17 ;
objCTree.Successor(*i,j);
objCTree.Predecessor(*i,j);
*/
//InOrderTreeWalk
*i=15;
objCTree.TreeInorderWalk(*i);
objCTree.TreeInorderWalk(*i);
//*i=3;
objCTree.TreeInorderWalk(*i);
objCTree.TreeInorderWalk(*i);
//PreOrderTreeWalk
*i=15;
objCTree.TreePreorderWalk(*i);
objCTree.TreePreorderWalk(*i);
//*i=3;
objCTree.TreePreorderWalk(*i);
objCTree.TreePreorderWalk(*i);
//PostOrderTreeWalk
*i=15;
objCTree.TreePostorderWalk(*i);
objCTree.TreePostorderWalk(*i);
//*i=3;
objCTree.TreePostorderWalk(*i);
objCTree.TreePostorderWalk(*i);
/**i=15 ;
objCTree.Search(*i,&pNode) ;
if(!pNode) {
cout<<"\nNot Found\n"<<endl;
}
objCTree.DeleteTree(*i);*/
/*
// test list
objCTree.m_pListInorder->AddToFirst(*i) ;
objCTree.m_pListInorder->DeleteLast() ;
objCTree.m_pListInorder->GetNode(*i,&pListNode) ;
*/
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am currently working with Microsoft at Bangalore (India). My interest lies in areas of generic C++ and windows development. Apart from office hours I try to develop new and useful small tools.
Well, I still feel that I need to be more serious..!