void InsertTestB() { cout << "--------------------------Insert TestB---------------------------" << endl; RedBlackTree<int> tree; tree.Insert(20); tree.Insert(3); tree.Insert(7); tree.Insert(5); tree.Insert(6); tree.Insert(10); tree.Insert(21); tree.Insert(23); cout << "New Tree..." << endl; cout << "Verify Red Black Tree..." << endl; tree.verify(tree); RedBlackTree<int> treeC(tree); cout << "Copy And Insert..." << endl; treeC.Insert(55); treeC.Insert(9); treeC.Insert(11); treeC.Insert(777); cout << "Verify Copy and Inserted Red Black Tree..." << endl; treeC.verify(treeC); cout << endl; }
void CopyTest() { cout << "--------------------------CopyTest---------------------------" << endl; RedBlackTree<int> tree; cout << "Create Tree..." << endl; tree.Insert(6); tree.Insert(77); tree.Insert(1); tree.Insert(9); tree.Insert(11); tree.Insert(5); cout << endl << "Verify Red Black Tree..." << endl; tree.verify(tree); cout << "Size: " << tree.Size() << endl; RedBlackTree<int> treeC(tree); cout << "Perform Copy Tree..." << endl; cout << "Size of Copy: " << treeC.Size() << endl; cout << endl << "Verify Copy Red Black Tree..." << endl; treeC.verify(treeC); cout << "Remove 2 Elements of Copy" << endl; treeC.Remove(5); treeC.Remove(1); cout << "Size of Copy: " << treeC.Size() << endl; //Verify order of Tree cout << endl << "Verify Copy Red Black Tree..." << endl; treeC.verify(treeC); cout << endl; }
void ConstructorTest() { cout << "--------------------------Constructor Test---------------------------" << endl; RedBlackTree<int> tree; cout << "Create Tree..." << endl; tree.Insert(6); tree.Insert(7); tree.Insert(8); tree.Insert(9); tree.Insert(11); tree.Insert(2); tree.Insert(1); tree.Insert(3); tree.Insert(4); tree.Insert(5); cout << endl << "Verify Red Black Tree..." << endl; tree.verify(tree); RedBlackTree<int> treeC(tree); cout << "Perform Copy Tree..." << endl; cout << "Size of Copy: " << treeC.Size() << endl; //Verify order of Tree cout << endl << "Verify Copy Red Black Tree..." << endl; treeC.verify(treeC); cout << "Copy Blank Tree..." << endl; RedBlackTree<int> treeA; cout << "Size of Empty tree1: " << treeA.Size() << endl; RedBlackTree<int> treeC2(treeA); cout << "Size of Copy of tree1: " << treeC2.Size() << endl; //BST NOT RED BLACK (FOR COMPARE)!!! RedBlackTree<int> BST; BST.BSTInsert2(6);BST.BSTInsert2(7); BST.BSTInsert2(8);BST.BSTInsert2(9); BST.BSTInsert2(11);BST.BSTInsert2(2); BST.BSTInsert2(1);BST.BSTInsert2(3); BST.BSTInsert2(4);BST.BSTInsert2(5); cout << endl << "BST Verify..." << endl << "**NOT RED BLACK TREE**" << endl << endl; BST.verify(BST); cout << endl; }
void HeightTest() { cout << "--------------------------Height Test---------------------------" << endl; RedBlackTree<int> tree; cout<< "Creat Tree..." << endl; cout << "Height: " << tree.Height() << endl; cout << "Insert 1" << endl; tree.Insert(1); cout << "Height: " << tree.Height() << endl <<endl ; cout << "Insert 5 Item" << endl; tree.Insert(20); tree.Insert(3); tree.Insert(7); tree.Insert(5); tree.Insert(6); tree.Insert(10); tree.Insert(21); tree.Insert(23); cout << "Height: " << tree.Height() << endl; cout << "Verify Red Black Tree..." << endl; tree.verify(tree); cout << "Remove 1" << endl; tree.Remove(1); cout << "Height: " << tree.Height() << endl <<endl ; cout << "Remove All..." << endl; tree.RemoveAll(); cout << "Height: " << tree.Height() << endl; cout << "Verify Red Black Tree..." << endl; tree.verify(tree); cout << endl; }
void AssignmentTest() { cout << "--------------------------AssignmentTest---------------------------" << endl; cout << endl << "Basic Tree Size of Four" << endl; cout << "Insert.." << endl; RedBlackTree<int> tree; tree.Insert(5); tree.Insert(4); tree.Insert(3); tree.Insert(2); cout << "Verify Red Black Tree 1..." << endl; tree.verify(tree); RedBlackTree<int> tree2; cout << "Assign Tree 1 to Tree 2..." << endl << endl; tree2 = tree; cout << "Verify Red Black Tree 2..." << endl; tree2.verify(tree2); cout << "Creat Blank Tree..." << endl ; RedBlackTree<int> treeEmpty; cout << "Size: " << treeEmpty.Size() << endl << endl; RedBlackTree<int> tree3(tree); cout << "Creat Tree3 Copy of Tree1..." << endl ; cout << "Insert..." << endl; tree3.Insert(3); tree3.Insert(2); cout << "Verify Red Black Tree 3..." << endl; tree3.verify(tree3); cout << "Assign Tree3 to Empty Tree..." << endl << endl; cout << "Verify Red Black Tree 3..." << endl; tree3 = treeEmpty; tree3.verify(tree3); cout << endl; }
void RemoveTest2() { cout << "--------------------------RemoveTest2---------------------------" << endl; RedBlackTree<int> tree; tree.Insert(20); tree.Insert(3); tree.Insert(7); tree.Insert(5); tree.Insert(6); tree.Insert(10); tree.Insert(21); tree.Insert(23); cout << endl << "New Tree..." << endl; cout << "Verify Red Black Tree..." << endl; tree.verify(tree); cout << "Remove Root..." << endl; tree.Remove(7); cout << "Verify Red Black Tree..." << endl; tree.verify(tree); cout << "New Tree2..." << endl; RedBlackTree<int> tree2; tree2.Insert(5); tree2.Insert(6); tree2.Insert(3); tree2.Insert(1); tree2.Insert(8); tree2.Insert(23); tree2.Insert(11); tree2.Insert(24); tree2.Insert(10); tree2.Insert(4); tree2.Insert(2); tree2.Insert(25); cout << endl << "Verify Red Black Tree2..." << endl; tree2.verify(tree2); cout << "Remove 5 Elements (6 24 11 3 8)..." << endl; tree2.Remove(6); cout << endl << "Verify Red Black Tree2..." << endl; tree2.verify(tree2); tree2.Remove(24); cout << endl << "Verify Red Black Tree2..." << endl; tree2.verify(tree2); tree2.Remove(11); cout << endl << "Verify Red Black Tree2..." << endl; tree2.verify(tree2); tree2.Remove(3); cout << endl << "Verify Red Black Tree2..." << endl; tree2.verify(tree2); tree2.Remove(8); cout << endl << "Verify Red Black Tree2..." << endl; tree2.verify(tree2); cout << "Create Tree3..." << endl; RedBlackTree<int> tree3; tree3.Insert(5); tree3.Insert(6); tree3.Insert(3); tree3.Insert(1); tree3.Insert(8); tree3.Insert(23); tree3.Insert(11); tree3.Insert(24); tree3.Insert(10); tree3.Insert(4); tree3.Insert(2); tree3.Insert(25); tree3.Remove(6); tree3.Remove(24); tree3.Remove(11); tree3.Remove(3); tree3.Insert(6); cout << "Verify Red Black Tree3..." << endl; tree3.verify(tree3); cout << "Remove Root..." << endl; tree3.Remove(8); cout << "Verify Red Black Tree3..." << endl; tree3.verify(tree3); cout << endl; }