开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (3)
master
Prometheus
dev
master
分支 (3)
master
Prometheus
dev
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (3)
master
Prometheus
dev
test.cpp 21.58 KB
一键复制 编辑 原始数据 按行查看 历史
Y_Dash 提交于 2023年02月25日 17:28 +08:00 . 补充二叉搜索树系列的doxygen
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
/*!
* @file test.cpp
* @author CyberDash计算机考研, cyberdash@163.com(抖音id:cyberdash_yuan)
* @brief 二叉搜索树测试cpp文件
* @version 0.2.1
* @date 2023年02月25日
*/
#include "test.h"
#include "vector"
/*!
* @brief **搜索二叉树结点打印**
* @tparam Key 关键字类型模板参数
* @tparam Value 值类型模板参数
* @param node 结点
* @note
* 搜索二叉树结点打印
* ---------------
* ---------------
*
* ---------------
*/
template<typename Key, typename Value>
void BstNodePrint(BstNode<Key, Value>* node) {
cout << "[" << node->Key() << ":" << node->Value() << "]";
}
/*!
* @brief **AVL树结点打印**
* @tparam Key 关键字类型模板参数
* @tparam Value 值类型模板参数
* @param node 结点
* @note
* AVL树结点打印
* -----------
* -----------
*
* -----------
*/
template<typename Key, typename Value>
void AVLNodeVisit(AvlNode<Key, Value>* node) {
cout << "[" << node->Key() << ":" << node->Value() << "|" << node->BalanceFactor() << "]";
}
/*!
* @brief **AVL树结点Key打印**
* @tparam Key 关键字类型模板参数
* @tparam Value 值类型模板参数
* @param node 结点
* @note
* AVL树结点Key打印
* --------------
* --------------
*
* --------------
*/
template<typename Key, typename Value>
void VisitKey(AvlNode<Key, Value>* node) {
cout << node->Key() ;
}
/*!
* @brief **二叉搜索树_插入结点_测试**
* @note
* 二叉搜索树_插入结点_测试
* ---------------------
* ---------------------
*
* ---------------------
*/
void TestBstInsert() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test BinarySearchTree Insert |" << endl;
cout << "| 测试搜索二叉树的插入 |" << endl;
BinarySearchTree<string, string>* binary_search_tree = new BinarySearchTree<string, string>();
string question1 = "我最爱的乐队";
string answer1 = "林肯公园";
string question2 = "我最爱的游戏";
string answer2 = "Dota2";
string question3 = "我最爱的电影";
string answer3 = "《黑客帝国》";
binary_search_tree->InsertRecursive(question1, answer1);
binary_search_tree->InsertRecursive(question2, answer2);
binary_search_tree->InsertRecursive(question3, answer3);
BinarySearchTree<string, string> new_bst = *binary_search_tree;
new_bst.Print(BstNodePrint);
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **二叉搜索树_删除结点_测试**
* @note
* 二叉搜索树_删除结点_测试
* ---------------------
* ---------------------
*
* ---------------------
*/
void TestBstRemove() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test BinarySearchTree Remove |" << endl;
cout << "| 测试搜索二叉树的删除 |" << endl;
BinarySearchTree<string, string>* binary_search_tree = new BinarySearchTree<string, string>();
string question1 = "最爱的乐队";
string answer1 = "林肯公园";
string question2 = "最爱的游戏";
string answer2 = "Dota2";
string question3 = "最爱的电影";
string answer3 = "《黑客帝国》";
string question4 = "最爱的运动";
string answer4 = "足球";
string question5 = "最讨厌的编程语言";
string answer5 = "Java";
string question6 = "如果暴富了想干嘛";
string answer6 = "包养数学家";
string question7 = "推荐几首歌听";
string answer7 = "Learning To Survive|Final Masquerade|Nothing";
string question8 = "最后随便说句话";
string answer8 = "搞编程一定要爱这个世界, 否则只有折磨";
binary_search_tree->InsertRecursive(question1, answer1);
binary_search_tree->InsertRecursive(question2, answer2);
binary_search_tree->InsertRecursive(question3, answer3);
binary_search_tree->InsertRecursive(question4, answer4);
binary_search_tree->InsertRecursive(question5, answer5);
binary_search_tree->InsertRecursive(question6, answer6);
binary_search_tree->InsertRecursive(question7, answer7);
binary_search_tree->InsertRecursive(question8, answer8);
binary_search_tree->Print(BstNodePrint);
cout << endl;
binary_search_tree->RemoveRecursive(question1);
binary_search_tree->Print(BstNodePrint);
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **二叉搜索树_搜索_测试**
* @note
* 二叉搜索树_搜索_测试
* -----------------
* -----------------
*
* -----------------
*/
void TestBstSearch() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test BinarySearchTree Search |" << endl;
cout << "| 测试搜索二叉树的搜索 |" << endl;
BinarySearchTree<string, string>* binary_search_tree = new BinarySearchTree<string, string>();
string question1 = "最爱的乐队";
string answer1 = "林肯公园";
string question2 = "最爱的游戏";
string answer2 = "Dota2";
string question3 = "最爱的电影";
string answer3 = "《黑客帝国》";
string question4 = "最爱的运动";
string answer4 = "足球";
string question5 = "最讨厌的编程语言";
string answer5 = "Java";
string question6 = "如果暴富了想干嘛";
string answer6 = "包养数学家";
string question7 = "推荐几首歌听";
string answer7 = "Learning To Survive|Final Masquerade|Nothing";
string question8 = "最后随便说句话";
string answer8 = "搞编程一定要爱这个世界, 否则只有折磨";
string question9 = "讲一件后悔的事儿";
string answer9 = "烂到肚子里也不会说的";
binary_search_tree->InsertRecursive(question1, answer1);
binary_search_tree->InsertRecursive(question2, answer2);
binary_search_tree->InsertRecursive(question3, answer3);
binary_search_tree->InsertRecursive(question4, answer4);
binary_search_tree->InsertRecursive(question5, answer5);
binary_search_tree->InsertRecursive(question6, answer6);
binary_search_tree->InsertRecursive(question7, answer7);
binary_search_tree->InsertRecursive(question8, answer8);
binary_search_tree->InsertRecursive(question9, answer9);
binary_search_tree->RemoveRecursive(question9);
BstNode<string, string>* the_9th_node = binary_search_tree->Search(question9);
if (the_9th_node == NULL) { // 没有搜索到
cout << "此问题已删除" << endl;
} else { // 搜索到
cout << "question9: " << the_9th_node->Key() << endl << "answer9: " << the_9th_node->Value() << endl;
}
cout << endl;
BstNode<string, string>* the_8th_node = binary_search_tree->Search(question8);
if (the_8th_node == NULL) { // 没有搜索到
cout << "Duck不必" << endl;
} else { // 搜索到
cout << "question8: " << the_8th_node->Key() << endl << "answer8: " << the_8th_node->Value() << endl;
}
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **AVL树_搜索_测试**
* @note
* AVL树_搜索_测试
* -------------
* -------------
*
* -------------
*/
void TestAvlSearch() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test AVL Search |" << endl;
cout << "| 测试AVL树的搜索 |" << endl;
AvlTree<string, string>* AVL_tree = new AvlTree<string, string>();
string question1 = "最爱的乐队";
string answer1 = "林肯公园";
string question2 = "最爱的游戏";
string answer2 = "Dota2";
string question3 = "最爱的电影";
string answer3 = "《黑客帝国》";
string question4 = "最爱的运动";
string answer4 = "足球";
string question5 = "最讨厌的编程语言";
string answer5 = "Java";
string question6 = "如果暴富了想干嘛";
string answer6 = "包养数学家";
string question7 = "推荐几首歌听";
string answer7 = "Learning To Survive|Final Masquerade|Nothing";
string question8 = "最后随便说句话";
string answer8 = "搞编程一定要爱这个世界, 否则只有折磨";
string question9 = "讲一件后悔的事儿";
string answer9 = "烂到肚子里也不会说的";
AVL_tree->Insert(question1, answer1);
AVL_tree->Insert(question2, answer2);
AVL_tree->Insert(question3, answer3);
AVL_tree->Insert(question4, answer4);
AVL_tree->Insert(question5, answer5);
AVL_tree->Insert(question6, answer6);
AVL_tree->Insert(question7, answer7);
AVL_tree->Insert(question8, answer8);
AVL_tree->Insert(question9, answer9);
AVL_tree->Remove(question9);
AvlNode<string, string>* the_9th_node = AVL_tree->Search(question9);
if (!the_9th_node) { // 没有搜索到
cout << "此问题已删除" << endl;
} else { // 搜索到
cout << "question9: " << the_9th_node->Key() << endl << "answer9: " << the_9th_node->Value() << endl;
}
cout << endl;
AvlNode<string, string>* the_8th_node = AVL_tree->Search(question8);
if (!the_8th_node) { // 没有搜索到
cout << "Duck不必" << endl;
} else { // 搜索到
cout << "question8: " << the_8th_node->Key() << endl << "answer8: " << the_8th_node->Value() << endl;
}
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **二叉搜索树_最大值最小值_测试**
* @note
* 二叉搜索树_最大值最小值_测试
* ------------------------
* ------------------------
*
* ------------------------
*/
void TestBSTMaxAndMin() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test BinarySearchTree Max and Min |" << endl;
cout << "| 测试搜索二叉树的最大值/最小值 |" << endl;
BinarySearchTree<string, string>* binary_search_tree = new BinarySearchTree<string, string>();
string question1 = "最爱的乐队";
string answer1 = "林肯公园";
string question2 = "最爱的游戏";
string answer2 = "Dota2";
string question3 = "最爱的电影";
string answer3 = "《黑客帝国》";
string question4 = "最爱的运动";
string answer4 = "足球";
string question5 = "最讨厌的编程语言";
string answer5 = "Java";
string question6 = "如果暴富了想干嘛";
string answer6 = "包养数学家";
string question7 = "推荐几首歌听";
string answer7 = "Learning To Survive|Final Masquerade|Nothing";
string question8 = "最后随便说句话";
string answer8 = "搞编程一定要爱这个世界, 否则只有折磨";
string question9 = "讲一件后悔的事儿";
string answer9 = "那些无法形容的痛, 见不得光";
binary_search_tree->InsertRecursive(question1, answer1);
binary_search_tree->InsertRecursive(question2, answer2);
binary_search_tree->InsertRecursive(question3, answer3);
binary_search_tree->InsertRecursive(question4, answer4);
binary_search_tree->InsertRecursive(question5, answer5);
binary_search_tree->InsertRecursive(question6, answer6);
binary_search_tree->InsertRecursive(question7, answer7);
binary_search_tree->InsertRecursive(question8, answer8);
binary_search_tree->InsertRecursive(question9, answer9);
string max_data;
bool res = binary_search_tree->Max(max_data);
cout << "max_data: " << max_data << endl;
string min_data;
res = binary_search_tree->Min(min_data);
cout << "min_data: " << min_data << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **AVL树_最大值最小值_测试**
* @note
* AVL树_最大值最小值_测试
* --------------------
* --------------------
*
* --------------------
*/
void TestAVLMaxAndMin() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test AVL Max & Min |" << endl;
cout << "| 测试AVL树的最大值/最小值 |" << endl;
AvlTree<string, string>* AVL_tree = new AvlTree<string, string>();
string question1 = "最爱的乐队";
string answer1 = "林肯公园";
string question2 = "最爱的游戏";
string answer2 = "Dota2";
string question3 = "最爱的电影";
string answer3 = "《黑客帝国》";
string question4 = "最爱的运动";
string answer4 = "足球";
string question5 = "最讨厌的编程语言";
string answer5 = "Java";
string question6 = "如果暴富了想干嘛";
string answer6 = "包养数学家";
string question7 = "推荐几首歌听";
string answer7 = "Learning To Survive|Final Masquerade|Nothing";
string question8 = "最后随便说句话";
string answer8 = "搞编程一定要爱这个世界, 否则只有折磨";
string question9 = "讲一件后悔的事儿";
string answer9 = "那些无法形容的痛, 见不得光";
AVL_tree->Insert(question1, answer1);
AVL_tree->Insert(question2, answer2);
AVL_tree->Insert(question3, answer3);
AVL_tree->Insert(question4, answer4);
AVL_tree->Insert(question5, answer5);
AVL_tree->Insert(question6, answer6);
AVL_tree->Insert(question7, answer7);
AVL_tree->Insert(question8, answer8);
AVL_tree->Insert(question9, answer9);
string max_data;
bool res = AVL_tree->Max(max_data);
if (res) {
cout << "max_data: " << max_data << endl;
}
string min_data;
res = AVL_tree->Min(min_data);
if (res) {
cout << "min_data: " << min_data << endl;
}
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **二叉搜索树_清空_测试**
* @note
* 二叉搜索树_清空_测试
* -----------------
* -----------------
*
* -----------------
*/
void TestBstClear() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test BinarySearchTree Clear |" << endl;
cout << "| 测试搜索二叉树的清除 |" << endl;
BinarySearchTree<string, string>* binary_search_tree = new BinarySearchTree<string, string>();
string question1 = "最爱的乐队";
string answer1 = "林肯公园";
string question2 = "最爱的游戏";
string answer2 = "Dota2";
string question3 = "最爱的电影";
string answer3 = "《黑客帝国》";
string question4 = "最爱的运动";
string answer4 = "足球";
string question5 = "最讨厌的编程语言";
string answer5 = "Java";
string question6 = "如果暴富了想干嘛";
string answer6 = "包养数学家";
string question7 = "推荐几首歌听";
string answer7 = "Learning To Survive|Final Masquerade|Nothing";
string question8 = "最后随便说句话";
string answer8 = "搞编程一定要爱这个世界, 否则只有折磨";
string question9 = "讲一件后悔的事儿";
string answer9 = "烂到肚子里也不会说的";
binary_search_tree->InsertRecursive(question1, answer1);
binary_search_tree->InsertRecursive(question2, answer2);
binary_search_tree->InsertRecursive(question3, answer3);
binary_search_tree->InsertRecursive(question4, answer4);
binary_search_tree->InsertRecursive(question5, answer5);
binary_search_tree->InsertRecursive(question6, answer6);
binary_search_tree->InsertRecursive(question7, answer7);
binary_search_tree->InsertRecursive(question8, answer8);
binary_search_tree->InsertRecursive(question9, answer9);
binary_search_tree->Clear();
binary_search_tree->Print(BstNodePrint);
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **AVL树_插入结点_测试**
* @note
* AVL树_插入节点_测试
* -----------------
* -----------------
*
* -----------------
*/
void TestAVLInsert() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test AVL Insert |" << endl;
cout << "| 测试平衡二叉树的插入 |" << endl;
AvlTree<string, string>* AVL_tree = new AvlTree<string, string>();
string question1 = "a";
string answer1 = "a";
string question2 = "d";
string answer2 = "d";
string question3 = "c";
string answer3 = "c";
string question4 = "b";
string answer4 = "b";
AVL_tree->Insert(question1, answer1);
AVL_tree->Insert(question2, answer2);
AVL_tree->Insert(question3, answer3);
AVL_tree->Insert(question4, answer4);
AVL_tree->Print(AVLNodeVisit);
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **AVL树_插入结点和删除结点_测试**
* @note
* AVL树_插入结点和删除结点_测试
* --------------------------
* --------------------------
*
* --------------------------
*/
void TestAvlInsertAndRemove() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test AVL Insert/Remove |" << endl;
cout << "| 测试平衡二叉树的插入/删除 |" << endl;
AvlTree<int, int>* AVL_tree = new AvlTree<int, int>();
int keys[31] =
{ 9, 15, 5, 23, 27, 22, 7, 17, 8, 28,
25, 12, 13, 14, 2, 26, 30, 18, 16, 20,
21, 6, 4, 24, 11, 19, 3, 1, 29, 10, 10 };
int values[31] =
{ 9, 15, 5, 23, 27, 22, 7, 17, 8, 28,
25, 12, 13, 14, 2, 26, 30, 18, 16, 20,
21, 6, 4, 24, 11, 19, 3, 1, 29, 10, 10 };
int count = 30;
for (int i = 0; i < count; i++) {
AVL_tree->Insert(keys[i], values[i]);
AVL_tree->Print(VisitKey);
}
for (int i = 0; i < count; i++) {
int key = keys[i];
AVL_tree->Remove(key);
AVL_tree->Print(VisitKey);
}
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **AVL树_插入结点(递归)和删除结点(递归)_测试**
* @note
* AVL树_插入结点(递归)和删除结点(递归)_测试
* -------------------------------------
* -------------------------------------
*
* -------------------------------------
*/
void TestAvlInsertAndRemoveRecursive() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test AVL Insert/Remove recursive |" << endl;
cout << "| 测试平衡二叉树的插入/删除(递归) |" << endl;
AvlTree<int, int>* AVL_tree = new AvlTree<int, int>();
int keys[30] =
{ 9, 15, 5, 23, 27, 22, 7, 17, 8, 28,
25, 12, 13, 14, 2, 26, 30, 18, 16, 20,
21, 6, 4, 24, 11, 19, 3, 1, 29, 10 };
int values[30] =
{ 9, 15, 5, 23, 27, 22, 7, 17, 8, 28,
25, 12, 13, 14, 2, 26, 30, 18, 16, 20,
21, 6, 4, 24, 11, 19, 3, 1, 29, 10 };
int count = 30;
for (int i = 0; i < count; i++) {
AVL_tree->InsertRecursive(keys[i], values[i]);
AVL_tree->Print(VisitKey);
}
for (int i = 0; i < count; i++) {
int key = keys[i];
AVL_tree->RemoveRecursive(key);
AVL_tree->Print(VisitKey);
}
cout << endl;
cout << "-------------------------------------------------------------" << endl;
}
/*!
* @brief **二叉搜索树和AVL树_树高度_测试**
* @note
* 二叉搜索树和AVL树_树高度_测试
* -------------------------
* -------------------------
*
* -------------------------
*/
void TestBstAndAvlHeight() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test BinarySearchTree & AVL Height |" << endl;
cout << "| 测试搜索二叉树/AVL树的高度 |" << endl;
string keys[26] =
{ "a", "d", "b", "c", "e", "f", "g", "h", "i", "k", "l", "j", "z", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "m"};
string elements[26] =
{ "a", "d", "b", "c", "e", "f", "g", "h", "i", "k", "l", "j", "z", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "m"};
int count = 26;
cout << "分别向BST和AVL树插入:" << endl;
for (int i = 0; i < count; i++) {
cout << "\"key:" << keys[i] << "/elem:" << elements[i] << "\" ";
// 四个一行
if (i % 4 == 3 && i != 0) {
cout << endl;
}
}
BinarySearchTree<string, string>* bst_tree = new BinarySearchTree<string, string>();
AvlTree<string, string>* AVL_tree = new AvlTree<string, string>();
for (int i = 0; i < count; i++) {
bst_tree->InsertRecursive(keys[i], elements[i]);
}
for (int i = 0; i < count; i++) {
AVL_tree->Insert(keys[i], elements[i]);
}
cout << endl << endl;
cout << "BST树高度: " << bst_tree->Height() << endl;
cout << "AVL树高度: " << AVL_tree->Height() << endl;
cout << "-------------------------------------------------------------" << endl;
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

通用的C++数据结构代码实现,使用模板
暂无标签
MulanPSL-2.0
使用 MulanPSL-2.0 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/code367/data-structures-cpp.git
git@gitee.com:code367/data-structures-cpp.git
code367
data-structures-cpp
数据结构(C++模板实现)
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /