Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- void NextEffectiveness() {
- using namespace std;
- using T = TreeNode<int>;
- T* root = MakeTree(0, nullptr, 0, 20);
- cout << root << endl;
- T* iter = begin(root);
- while (iter) {
- cout << iter->value << " "s;
- iter = next(iter);
- }
- cout << endl;
- DeleteTree(root);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement