Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- namespace lab3{
- struct TreeNode {
- int val;
- vector<TreeNode*> childs;
- TreeNode() : val(0), childs(vector<TreeNode*>(2, nullptr)) { }
- TreeNode(int x) : val(x), childs(vector<TreeNode*>(2, nullptr)) { }
- };
- void Add(TreeNode *&tree, int x) {
- if (tree == nullptr)
- tree = new TreeNode(x);
- else
- if (tree->val < x)
- Add(tree->childs[0], x);
- else
- Add(tree->childs[1], x);
- }
- }
- #ifndef ALGORITHMS_LAB3_H
- #define ALGORITHMS_LAB3_H
- #endif //ALGORITHMS_LAB3_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement