|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Demonstrates BST join operation and generates visualization files. More...
#include <iostream>#include <fstream>#include <tclap/CmdLine.h>#include <aleph.H>#include <tpl_binNodeUtils.H>#include <tpl_binNodeXt.H>Go to the source code of this file.
Typedefs | |
| typedef BinNode< int > | Node |
Functions | |
| void | print_key (Node *p, int, int) |
| void | print_key1 (Node *p, int, int) |
| void | print_key2 (Node *p, int, int) |
| int | main (int argc, char *argv[]) |
Variables | |
| ofstream | output |
| ofstream | output1 |
| ofstream | output2 |
Demonstrates BST join operation and generates visualization files.
This program demonstrates the join operation for binary search trees, which combines two BSTs into a single BST while maintaining the BST property. Join is a fundamental operation that enables efficient tree manipulation and is the inverse of the split operation.
The join operation combines two BSTs T₁ and T₂ where:
The join operation works by:
| Tree Type | Complexity | Notes |
|---|---|---|
| Balanced | O(log n) | Height is O(log n) |
| Unbalanced | O(n) | Worst case height is O(n) |
| With rank info | O(log n) | Can use rank for efficiency |
Join is used in:
writeSplit.C)join-1-aux.Tree**: First BST before join (preorder)join-2-aux.Tree**: Second BST before join (preorder)join-aux.Tree**: Resulting joined BST (preorder)All files can be visualized with btreepic to see the transformation.
Definition in file writeJoin.C.
Definition at line 221 of file writeJoin.C.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 243 of file writeJoin.C.
References Aleph::check_bst(), Aleph::computeHeightRec(), Aleph::destroyRec(), Aleph::insert_in_bst(), Aleph::insert_root(), Aleph::join(), Aleph::maps(), Aleph::BinNode< Key >::NullPtr, output, output1, output2, Aleph::preOrderRec(), print_key(), print_key1(), print_key2(), root(), and Aleph::searchInBinTree().
| void print_key | ( | Node * | p, |
| int | , | ||
| int | |||
| ) |
Definition at line 228 of file writeJoin.C.
References Aleph::BinNode< Key >::get_key(), and output.
Referenced by main().
| void print_key1 | ( | Node * | p, |
| int | , | ||
| int | |||
| ) |
| void print_key2 | ( | Node * | p, |
| int | , | ||
| int | |||
| ) |
| ofstream output |
Definition at line 224 of file writeJoin.C.
Referenced by main(), and print_key().
| ofstream output1 |
Definition at line 225 of file writeJoin.C.
Referenced by main(), and print_key1().
| ofstream output2 |
Definition at line 226 of file writeJoin.C.
Referenced by main(), and print_key2().