-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestAvlTree.cpp
executable file
·51 lines (41 loc) · 1.08 KB
/
TestAvlTree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include "AvlTree.h"
using namespace std;
// Test program
int main( )
{
AvlTree<int> t;
int NUMS = 2000000;
const int GAP = 37;
int i;
cout << "Checking... (no more output means success)" << endl;
for( i = GAP; i != 0; i = ( i + GAP ) % NUMS )
t.insert( i );
t.remove( 0 );
for( i = 1; i < NUMS; i += 2 )
t.remove( i );
if( NUMS < 40 )
t.printTree( );
if( t.findMin( ) != 2 || t.findMax( ) != NUMS - 2 )
cout << "FindMin or FindMax error!" << endl;
for( i = 2; i < NUMS; i += 2 )
if( !t.contains( i ) )
cout << "Find error1!" << endl;
for( i = 1; i < NUMS; i += 2 )
{
if( t.contains( i ) )
cout << "Find error2!" << endl;
}
AvlTree<int> t2;
t2 = t;
for( i = 2; i < NUMS; i += 2 )
if( !t2.contains( i ) )
cout << "Find error1!" << endl;
for( i = 1; i < NUMS; i += 2 )
{
if( t2.contains( i ) )
cout << "Find error2!" << endl;
}
cout << "End of test..." << endl;
return 0;
}