示例#1
0
文件: test.cpp 项目: natemara/CSE-274
void TestBinaryTreeHeight2() {
  BinarySearchTree<BSTNode1<int>, int> b;
  int test = 0;

  for (int i = 0; i < 10000; i++) {
    test = rand() % 100000;
    b.add(test);
  }

  assert(b.height() - b.depth(b.getNode(test)) == b.height2(b.getNode(test)));
  assert(b.height2(b.getRoot()) == b.height());
}
示例#2
0
void testPart1(){
	BinarySearchTree<BSTNode1<int>, int> tree = treeMaker(1);
	BSTNode1<int>* node = tree.getNode(10);
	cout << tree.size() << endl;
	cout << tree.height() << endl;
	cout << tree.height2(node) << endl << endl;
	BinarySearchTree<BSTNode1<int>, int> tree2 = treeMaker(2);
	BSTNode1<int>* node2 = tree2.getNode(20);
	cout << tree2.size() << endl;
	cout << tree2.height() << endl;
	cout << tree2.height2(node2) << endl << "END1" << endl;
}
示例#3
0
文件: test.cpp 项目: rakhlei/cse274b
void testPart1() {
	cout << "Part 1" << endl;
	BinarySearchTree<BSTNode1<int>, int> tree;
	tree.add(15);
	tree.add(5);
	tree.add(16);
	tree.add(3);
	tree.add(12);
	tree.add(10);
	tree.add(13);
	tree.add(6);
	tree.add(7);
	tree.add(20);
	tree.add(18);
	tree.add(23);

	cout << "height of node: " << tree.height2(tree.getNode(5)) << endl;
	cout << "height of tree: " << tree.height() << endl;
	cout << endl;
}