-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTree.h
64 lines (58 loc) · 1.59 KB
/
Tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Created by Rohan Chander on 8/1/22.
//
#pragma once
#ifndef TREE_CAR_REC_SERVICE_TREE_H
#define TREE_CAR_REC_SERVICE_TREE_H
#include <iostream>
#include "Car.h"
#include <vector>
class Tree{
private:
struct Node{
bool leaf;
vector<Car*> block;
vector<Node*> children;
int size;
Node* parent;
Node (Car* car){
this->leaf = false;
this->size = 0;
this->block = {car};
this->children = {};
this->parent = nullptr;
}
Node(){
this->leaf = false;
this->size = 0;
this->block = {};
this->children = {};
this->parent = nullptr;
}
};
int maxNumChildren;
//int height;
Node* root;
int blockSize;
int size;
//this vector acts as the bottom linked list
vector<Car*> leafNodes;
public:
// B+ Tree constructor
Tree();
Tree(int maxNumChildren, int blockSize);
// Insert car in block vector in ascending location
void BlockInsertion(vector<Car*>& block,Car* car);
// Insert car in
void ChildBlockInsertion(Node* parent, Node* child, Car* car);
// Insert car in
void ParentalInsert(Node* parent, Node* child, Car* car);
// Insert car into Tree
void Insert(Car* car);
//Searches through tree
vector<Car*> Search(Node* root, int lowerYear, int upperYeat);
//inserts into leaf node vector
void leafNodeInsertion(Car* toBeInserted, int indexFirstCarInNode, int indexLastCarInNode);
Node *getRoot() const;
};
#endif //TREE_CAR_REC_SERVICE_TREE_H