#include <cassert>
#include <functional>
@@ -157,7 +157,7 @@ Functions
| |
-
A generic binary search tree implementation.
+
A generic binary search tree implementation. Here you can find more information about the algorithm: Scaler - Binary Search tree.
- See also
- binary_search_tree.cpp
@@ -175,24 +175,24 @@ Functions
-
555 {
-
-
-
-
-
-
-
-
-
564}
-
static void test_get_elements_inorder()
Function for testing get_elements_inorder().
Definition: binary_search_tree2.cpp:497
-
static void test_contains()
Function for testing contains().
Definition: binary_search_tree2.cpp:428
-
static void test_insert()
Function for testing insert().
Definition: binary_search_tree2.cpp:357
-
static void test_get_elements_postorder()
Function for testing get_elements_postorder().
Definition: binary_search_tree2.cpp:539
-
static void test_find_max()
Function for testing find_max().
Definition: binary_search_tree2.cpp:474
-
static void test_get_elements_preorder()
Function for testing get_elements_preorder().
Definition: binary_search_tree2.cpp:518
-
static void test_remove()
Function for testing remove().
Definition: binary_search_tree2.cpp:391
-
static void test_find_min()
Function for testing find_min().
Definition: binary_search_tree2.cpp:451
+
556 {
+
+
+
+
+
+
+
+
+
565}
+
static void test_get_elements_inorder()
Function for testing get_elements_inorder().
Definition: binary_search_tree2.cpp:498
+
static void test_contains()
Function for testing contains().
Definition: binary_search_tree2.cpp:429
+
static void test_insert()
Function for testing insert().
Definition: binary_search_tree2.cpp:358
+
static void test_get_elements_postorder()
Function for testing get_elements_postorder().
Definition: binary_search_tree2.cpp:540
+
static void test_find_max()
Function for testing find_max().
Definition: binary_search_tree2.cpp:475
+
static void test_get_elements_preorder()
Function for testing get_elements_preorder().
Definition: binary_search_tree2.cpp:519
+
static void test_remove()
Function for testing remove().
Definition: binary_search_tree2.cpp:392
+
static void test_find_min()
Function for testing find_min().
Definition: binary_search_tree2.cpp:452
@@ -221,27 +221,27 @@ Functions
Function for testing contains().
- Returns
void
-
428 {
-
-
430
-
-
-
-
-
-
436
-
-
-
-
-
-
442
-
-
444}
+
429 {
+
+
431
+
+
+
+
+
+
437
+
+
+
+
+
+
443
+
+
445}
-
The Binary Search Tree class.
Definition: binary_search_tree2.cpp:19
-
bool insert(std::unique_ptr< bst_node > &node, T new_value)
Recursive function to insert a value into the BST.
Definition: binary_search_tree2.cpp:89
-
bool contains(std::unique_ptr< bst_node > &node, T value)
Recursive function to check if a value is in the BST.
Definition: binary_search_tree2.cpp:176
+
The Binary Search Tree class.
Definition: binary_search_tree2.cpp:20
+
bool insert(std::unique_ptr< bst_node > &node, T new_value)
Recursive function to insert a value into the BST.
Definition: binary_search_tree2.cpp:90
+
bool contains(std::unique_ptr< bst_node > &node, T value)
Recursive function to check if a value is in the BST.
Definition: binary_search_tree2.cpp:177
@@ -277,24 +277,24 @@ Here is the call graph for this function:
Function for testing find_max().
- Returns
void
-
474 {
-
-
476
-
-
-
-
480
-
-
-
-
-
485
-
-
487 assert(max == 6);
-
488
-
-
490}
-
bool find_max(std::unique_ptr< bst_node > &node, T &ret_value)
Recursive function to find the maximum value in the BST.
Definition: binary_search_tree2.cpp:52
+
475 {
+
+
477
+
+
+
+
481
+
+
+
+
+
486
+
+
488 assert(max == 6);
+
489
+
+
491}
+
bool find_max(std::unique_ptr< bst_node > &node, T &ret_value)
Recursive function to find the maximum value in the BST.
Definition: binary_search_tree2.cpp:53
@@ -330,24 +330,24 @@ Here is the call graph for this function:
Function for testing find_min().
- Returns
void
-
451 {
-
-
453
-
-
-
-
457
-
-
-
-
-
462
-
-
464 assert(min == 3);
-
465
-
-
467}
-
bool find_min(std::unique_ptr< bst_node > &node, T &ret_value)
Recursive function to find the minimum value in the BST.
Definition: binary_search_tree2.cpp:70
+
452 {
+
+
454
+
+
+
+
458
+
+
+
+
+
463
+
+
465 assert(min == 3);
+
466
+
+
468}
+
bool find_min(std::unique_ptr< bst_node > &node, T &ret_value)
Recursive function to find the minimum value in the BST.
Definition: binary_search_tree2.cpp:71
@@ -383,22 +383,22 @@ Here is the call graph for this function:
Function for testing get_elements_inorder().
- Returns
void
-
497 {
-
498 std::cout <<
"Testing BST get_elements_inorder...";
-
499
-
-
-
-
-
-
505
-
-
-
508 assert(actual == expected);
-
509
-
-
511}
-
std::vector< T > get_elements_inorder()
Get all values of the BST in in-order order.
Definition: binary_search_tree2.cpp:320
+
498 {
+
499 std::cout <<
"Testing BST get_elements_inorder...";
+
500
+
+
+
+
+
+
506
+
+
+
509 assert(actual == expected);
+
510
+
+
512}
+
std::vector< T > get_elements_inorder()
Get all values of the BST in in-order order.
Definition: binary_search_tree2.cpp:321
@@ -434,22 +434,22 @@ Here is the call graph for this function:
Function for testing get_elements_postorder().
- Returns
void
-
539 {
-
540 std::cout <<
"Testing BST get_elements_postorder...";
-
541
-
-
-
-
-
-
547
-
-
-
550 assert(actual == expected);
-
551
-
-
553}
-
std::vector< T > get_elements_postorder()
Get all values of the BST in post-order order.
Definition: binary_search_tree2.cpp:344
+
540 {
+
541 std::cout <<
"Testing BST get_elements_postorder...";
+
542
+
+
+
+
+
+
548
+
+
+
551 assert(actual == expected);
+
552
+
+
554}
+
std::vector< T > get_elements_postorder()
Get all values of the BST in post-order order.
Definition: binary_search_tree2.cpp:345
@@ -484,22 +484,22 @@ Here is the call graph for this function:
Function for testing get_elements_preorder().
- Returns
void
-
518 {
-
519 std::cout <<
"Testing BST get_elements_preorder...";
-
520
-
-
-
-
-
-
526
-
-
-
529 assert(actual == expected);
-
530
-
-
532}
-
std::vector< T > get_elements_preorder()
Get all values of the BST in pre-order order.
Definition: binary_search_tree2.cpp:332
+
519 {
+
520 std::cout <<
"Testing BST get_elements_preorder...";
+
521
+
+
+
+
+
+
527
+
+
+
530 assert(actual == expected);
+
531
+
+
533}
+
std::vector< T > get_elements_preorder()
Get all values of the BST in pre-order order.
Definition: binary_search_tree2.cpp:333
@@ -534,35 +534,35 @@ Here is the call graph for this function:
Function for testing insert().
- Returns
void
-
357 {
-
-
359
-
-
361 bool res = tree.
insert(5);
-
-
363 assert(res);
-
-
-
366 assert(max == 5);
-
367 assert(min == 5);
-
368 assert(tree.
size() == 1);
-
369
-
-
-
-
-
-
375 assert(max == 6);
-
376 assert(min == 3);
-
377 assert(tree.
size() == 4);
-
378
-
379 bool fail_res = tree.
insert(4);
-
380 assert(!fail_res);
-
381 assert(tree.
size() == 4);
-
382
-
-
384}
-
std::size_t size()
Get the number of values in the BST.
Definition: binary_search_tree2.cpp:313
+
358 {
+
+
360
+
+
362 bool res = tree.
insert(5);
+
+
364 assert(res);
+
+
+
367 assert(max == 5);
+
368 assert(min == 5);
+
369 assert(tree.
size() == 1);
+
370
+
+
+
+
+
+
376 assert(max == 6);
+
377 assert(min == 3);
+
378 assert(tree.
size() == 4);
+
379
+
380 bool fail_res = tree.
insert(4);
+
381 assert(!fail_res);
+
382 assert(tree.
size() == 4);
+
383
+
+
385}
+
std::size_t size()
Get the number of values in the BST.
Definition: binary_search_tree2.cpp:314
@@ -597,38 +597,38 @@ Here is the call graph for this function:
Function for testing remove().
- Returns
void
-
391 {
-
-
393
-
-
-
-
-
-
399
-
400 bool res = tree.
remove(5);
-
-
402 assert(res);
-
-
-
405 assert(max == 6);
-
406 assert(min == 3);
-
407 assert(tree.
size() == 3);
-
-
409
-
-
-
-
413 assert(tree.
size() == 0);
-
-
415
-
416 bool fail_res = tree.
remove(5);
-
417 assert(!fail_res);
-
418 assert(tree.
size() == 0);
-
419
-
-
421}
-
bool remove(std::unique_ptr< bst_node > &parent, std::unique_ptr< bst_node > &node, T rm_value)
Recursive function to remove a value from the BST.
Definition: binary_search_tree2.cpp:124
+
392 {
+
+
394
+
+
+
+
+
+
400
+
401 bool res = tree.
remove(5);
+
+
403 assert(res);
+
+
+
406 assert(max == 6);
+
407 assert(min == 3);
+
408 assert(tree.
size() == 3);
+
+
410
+
+
+
+
414 assert(tree.
size() == 0);
+
+
416
+
417 bool fail_res = tree.
remove(5);
+
418 assert(!fail_res);
+
419 assert(tree.
size() == 0);
+
420
+
+
422}
+
bool remove(std::unique_ptr< bst_node > &parent, std::unique_ptr< bst_node > &node, T rm_value)
Recursive function to remove a value from the BST.
Definition: binary_search_tree2.cpp:125
diff --git a/dir_2e746e9d06bf2d8ff842208bcc6ebcfc.html b/dir_2e746e9d06bf2d8ff842208bcc6ebcfc.html
index ba9f908f4..06e2d2f9e 100644
--- a/dir_2e746e9d06bf2d8ff842208bcc6ebcfc.html
+++ b/dir_2e746e9d06bf2d8ff842208bcc6ebcfc.html
@@ -115,7 +115,7 @@ Files
| | A simple tree implementation using structured nodes.
|
| |
| file | binary_search_tree2.cpp |
-
| | A generic binary search tree implementation.
|
+
| | A generic binary search tree implementation. Here you can find more information about the algorithm: Scaler - Binary Search tree.
|
| |
| file | binaryheap.cpp |
| | A C++ program to demonstrate common Binary Heap Operations.
|
diff --git a/files.html b/files.html
index 6f5001cc7..7c3323e30 100644
--- a/files.html
+++ b/files.html
@@ -139,7 +139,7 @@ solve-a-rat-in-a-maze-c-java-pytho/" target="_blank">Rat in a Maze algorithm
| cll.h | |
| avltree.cpp | A simple tree implementation using nodes |
| binary_search_tree.cpp | A simple tree implementation using structured nodes |
-
| binary_search_tree2.cpp | A generic binary search tree implementation |
+
| binary_search_tree2.cpp | A generic binary search tree implementation. Here you can find more information about the algorithm: Scaler - Binary Search tree |
| binaryheap.cpp | A C++ program to demonstrate common Binary Heap Operations |
| disjoint_set.cpp | Disjoint Sets Data Structure (Disjoint Sets) |
| dsu_path_compression.cpp | DSU (Disjoint sets) |