Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <exception>
- #include <cmath>
- #include <unordered_set>
- #include <vector>
- #include <unordered_map>
- #include <algorithm>
- using namespace std;
- constint inf = 2e9;
- struct node{
- node* self;
- node* parent;
- node* l;
- node* r;
- int vall
- node(par) : parent(par), l(nullptr), r(nullptr), self(this), val(inf) {}
- node() : parent(nullptr), l(nullptr), r(nullptr), self(this),val (inf) {}
- node(node *par, node *L, node *R) : parent(par), l(L), r(R), self(this), val(inf) {}
- };
- struct tree{
- vector <int> a = {1, 2, 3, 4, 5};
- node main_root;
- node create_subtree(node* par, int Li, int Ri) {
- /*Ri == Li + 2 - работает по алгоритмы
- Ri == Li + 1 - особ случ
- Ri == Li - особ случ*/
- node root(par);
- node left_root;
- node right_root;
- if (Ri == Li) {
- return root;
- }
- if (Ri == Li + 1) { //Ri - root, Li - left_root
- left_root = create_subtree(Li, Li);
- root.l = left_root;
- return root;
- }
- root.self = &arr[len / 2];
- left_root = create_subtree(0, len / 2 - 1);
- right_root = create_subtree(len / 2 + 1, len - 1);
- root.l = left_root.self;
- root.r = right_root.self;
- return root;
- }
- void create(vector <int> arr) {
- a = arr;
- int len = a.size();
- create_subtree(0, len);
- return;
- }
- void output() {
- return;
- }
- void find_first(int* v) {
- return;
- }
- void find_nex(int* v) {
- return;
- }
- void insert_after(int* v) { //а insert_defore надо?
- return;
- }
- };
- int main() {
- tree T;
- vector <int> a = {1, 2, 3, 4, 5};
- T()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement