Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ( 0 ( -32 ( -48 ( -56 ( -60 ( -62 ( -63 ) ( -61 ) ) ( -58 ( -59 ) ( -57 ) ) ) ( -52 ( -54 ( -55 ) ( -53 ) ) ( -50 ( -51 ) ( -49 ) ) ) ) ( -40 ( -44 ( -46 ( -47 ) ( -45 ) ) ( -42 ( -43 ) ( -41 ) ) ) ( -36 ( -38 ( -39 ) ( -37 ) ) ( -34 ( -35 ) ( -33 ) ) ) ) ) ( -16 ( -24 ( -28 ( -30 ( -31 ) ( -29 ) ) ( -26 ( -27 ) ( -25 ) ) ) ( -20 ( -22 ( -23 ) ( -21 ) ) ( -18 ( -19 ) ( -17 ) ) ) ) ( -8 ( -12 ( -14 ( -15 ) ( -13 ) ) ( -10 ( -11 ) ( -9 ) ) ) ( -4 ( -6 ( -7 ) ( -5 ) ) ( -2 ( -3 ) ( -1 ) ) ) ) ) ) ( 32 ( 16 ( 8 ( 4 ( 2 ( 1 ) ( 3 ) ) ( 6 ( 5 ) ( 7 ) ) ) ( 12 ( 10 ( 9 ) ( 11 ) ) ( 14 ( 13 ) ( 15 ) ) ) ) ( 24 ( 20 ( 18 ( 17 ) ( 19 ) ) ( 22 ( 21 ) ( 23 ) ) ) ( 28 ( 26 ( 25 ) ( 27 ) ) ( 30 ( 29 ) ( 31 ) ) ) ) ) ( 48 ( 40 ( 36 ( 34 ( 33 ) ( 35 ) ) ( 38 ( 37 ) ( 39 ) ) ) ( 44 ( 42 ( 41 ) ( 43 ) ) ( 46 ( 45 ) ( 47 ) ) ) ) ( 56 ( 52 ( 50 ( 49 ) ( 51 ) ) ( 54 ( 53 ) ( 55 ) ) ) ( 60 ( 58 ( 57 ) ( 59 ) ) ( 62 ( 61 ) ( 63 ) ) ) ) ) ) )
- ***
- ( 0 ( -32 ( -48 ( -56 ( -60 ( -62 ( -63 ) ( -61 ) ) ( -58 ( -59 ) ( -57 ) ) ) ( -52 ( -54 ( -55 ) ( -53 ) ) ( -50 ( -51 ) ( -49 ) ) ) ) ( -40 ( -44 ( -46 ( -47 ) ( -45 ) ) ( -42 ( -43 ) ( -41 ) ) ) ( -36 ( -38 ( -39 ) ( -37 ) ) ( -34 ( -35 ) ( -33 ) ) ) ) ) ( -16 ( -24 ( -28 ( -30 ( -31 ) ( -29 ) ) ( -26 ( -27 ) ( -25 ) ) ) ( -20 ( -22 ( -23 ) ( -21 ) ) ( -18 ( -19 ) ( -17 ) ) ) ) ( -8 ( -12 ( -14 ( -15 ) ( -13 ) ) ( -10 ( -11 ) ( -9 ) ) ) ( -4 ( -6 ( -7 ) ( -5 ) ) ( -2 ( -3 ) ( -1 ) ) ) ) ) ) ( 32 ( 16 ( 8 ( 4 ( 2 ( 1 ) ( 3 ) ) ( 6 ( 5 ) ( 7 ) ) ) ( 12 ( 10 ( 9 ) ( 11 ) ) ( 14 ( 13 ) ( 15 ) ) ) ) ( 24 ( 20 ( 18 ( 17 ) ( 19 ) ) ( 22 ( 21 ) ( 23 ) ) ) ( 28 ( 26 ( 25 ) ( 27 ) ) ( 30 ( 29 ) ( 31 ) ) ) ) ) ( 48 ( 40 ( 36 ( 34 ( 33 ) ( 35 ) ) ( 38 ( 37 ) ( 39 ) ) ) ( 44 ( 42 ( 41 ) ( 43 ) ) ( 46 ( 45 ) ( 47 ) ) ) ) ( 56 ( 52 ( 50 ( 49 ) ( 51 ) ) ( 54 ( 53 ) ( 55 ) ) ) ( 60 ( 58 ( 57 ) ( 59 ) ) ( 62 ( 61 ) ( 63 ) ) ) ) ) ) )
- ***
- TreeNode<int>* MakeTree(int value, TreeNode<int>* parent, int depth, int max_depth) {
- auto new_node = new TreeNode<int>{value, parent, nullptr, nullptr};
- if (depth <= max_depth) {
- new_node->left = MakeTree(value - (1<<(max_depth - depth)), new_node, depth + 1, max_depth);
- new_node->right = MakeTree(value + (1<<(max_depth - depth)), new_node, depth + 1, max_depth);
- }
- return new_node;
- }
- int main() {
- using namespace std;
- using T = TreeNode<int>;
- T* root = MakeTree(0, nullptr, 0, 5);
- cout << root << endl;
- T* iter = begin(root);
- while (iter) {
- iter = next(iter);
- }
- cout<<"\n\n***\n\n";
- cout << root << endl;
- cout<<"\n\n***\n\n";
- DeleteTree(root);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement