-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB_Tree.h
64 lines (58 loc) · 1.08 KB
/
B_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
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
#ifndef B_TREE_H
#define B_TREE_H
class Key
{
private:
int keyValue;
FILE *filePtr;
public:
Key();
Key(int, FILE *);
friend class Node;
friend class BTree;
};
class Node
{
private:
static int minimumDegree;
static int minimumNoOfKeys;
static int maximumNoOfKeys;
bool isLeaf;
int noOfKeys;
vector<Key> key;
vector<Node *> child;
friend class BTree;
public:
Node();
int findKey(int);
void deletion(int);
void removeFromLeaf(int);
void removeFromNonLeaf(int);
void fill(int);
Key getPredecessor(int);
Key getSuccessor(int);
void merge(int);
void borrowFromPrev(int);
void borrowFromNext(int);
};
class BTree
{
private:
static int minimumDegree;
Node *root;
Node *splitRoot();
void splitChild(Node *, int);
void insertInNonFullNode(Node *, Key);
FILE *recursiveSearch(Node *, int);
public:
BTree();
void insert(Key k);
FILE *search(int);
void display();
void deletion(int);
};
#endif