-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBalancedTreeK.h
More file actions
66 lines (45 loc) · 1.41 KB
/
BalancedTreeK.h
File metadata and controls
66 lines (45 loc) · 1.41 KB
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
65
66
//
// Created by Sgofman on 08-Jan-18.
//
#ifndef FINALALGO_BALANCEDTREEK_H
#define FINALALGO_BALANCEDTREEK_H
#include <cstddef>
#include "Value.h"
#include "Key.h"
#include "ParameterK.h"
#include "BTKNode.h"
class BalancedTreeK {
private:
BTKNode* root; //pointer default NULL
unsigned _k; //Minimum degree
Key* _min ;//pointer default NULL
Key* _max ;//pointer default NULL
public:
BalancedTreeK(const Key* min, const Key* max)
{
root = new BTKNode();
_min =min->clone(),_max =max->clone();
root->Children[0] = new BTKNode();
root->Children[0]->parent = root;
root->Children[0]->leaf = true;
root->Children[0]->key = _min;
root->Children[1] = new BTKNode();
root->Children[1]->parent = root;
root->Children[1]->leaf = true;
root->Children[1]->key = _max;
root->key = _max;
root->Cnum = 2;
_k= K;
}
~BalancedTreeK();
void Insert(const Key* nkey, const Value* nval);
void Delete(const Key* dkey);
Value* Search(const Key* key) const;
BTKNode* SearchLeaf(const Key* key) const ;
unsigned Rank(const Key* key) const;
const Key* Select(unsigned index) const;
const Value* GetMaxValue(const Key* key1, const Key* key2) const;
BTKNode* Successor(BTKNode* node) const;
BTKNode* Predeccessor(BTKNode* node) const;
};
#endif //FINALALGO_BALANCEDTREEK_H