Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISC_144 - B+ Tree Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
florian.burgener
ISC_144 - B+ Tree Project
Commits
be0feab1
You need to sign in or sign up before continuing.
Commit
be0feab1
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Progress of the implementation
parent
3ef0967e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/bptree.c
+45
-0
45 additions, 0 deletions
src/bptree.c
src/bptree.h
+18
-0
18 additions, 0 deletions
src/bptree.h
src/sorted_array.c
+4
-4
4 additions, 4 deletions
src/sorted_array.c
with
67 additions
and
4 deletions
src/bptree.c
0 → 100644
+
45
−
0
View file @
be0feab1
#include
"bptree.h"
#include
<stdbool.h>
#include
<stdlib.h>
///
static
bool
has_minimum_keys
(
BPTreeNode
*
root
);
static
bool
has_maximum_keys
(
BPTreeNode
*
root
);
static
bool
has_minimum_keys
(
BPTreeNode
*
root
)
{
return
root
->
keys_length
==
root
->
order
;
}
static
bool
has_maximum_keys
(
BPTreeNode
*
root
)
{
return
root
->
keys_length
==
2
*
root
->
order
;
}
///
BPTreeNode
*
bptree_init
(
int
order
)
{
BPTreeNode
*
root
=
(
BPTreeNode
*
)
malloc
(
sizeof
(
BPTreeNode
));
root
->
order
=
order
;
root
->
is_leaf
=
true
;
root
->
keys_length
=
0
;
root
->
keys
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
(
2
*
order
));
root
->
children_length
=
0
;
root
->
children
=
(
BPTreeNode
**
)
malloc
(
sizeof
(
BPTreeNode
*
)
*
(
2
*
order
+
1
));
return
root
;
}
void
bptree_destroy
(
BPTreeNode
**
root
)
{
for
(
int
i
=
0
;
i
<
(
*
root
)
->
children_length
;
i
++
)
{
bptree_destroy
((
*
root
)
->
children
[
i
]);
}
free
((
*
root
)
->
keys
);
free
((
*
root
)
->
children
);
free
(
*
root
);
*
root
=
NULL
;
}
// Insertion
// Deletion
This diff is collapsed.
Click to expand it.
src/bptree.h
+
18
−
0
View file @
be0feab1
#ifndef BPTREE_H
#define BPTREE_h
#include
"stdbool.h"
typedef
struct
BPTreeNode
{
int
order
;
bool
is_leaf
;
int
keys_length
;
int
*
keys
;
int
children_length
;
struct
BPTreeNode
**
children
;
}
BPTreeNode
;
BPTreeNode
*
bptree_init
(
int
order
);
void
bptree_destroy
(
BPTreeNode
**
root
);
#endif
This diff is collapsed.
Click to expand it.
src/sorted_array.c
+
4
−
4
View file @
be0feab1
...
...
@@ -61,15 +61,15 @@ void sorted_array_print(int *array, int array_length) {
}
int
sorted_array_insert
(
int
*
array
,
int
*
array_length
,
int
value
)
{
int
index
=
lower_bound
(
array
,
*
array_length
,
value
);
int
insertion_
index
=
lower_bound
(
array
,
*
array_length
,
value
);
for
(
int
i
=
*
array_length
-
1
;
i
>=
index
;
i
--
)
{
for
(
int
i
=
*
array_length
-
1
;
i
>=
insertion_
index
;
i
--
)
{
array
[
i
+
1
]
=
array
[
i
];
}
array
[
index
]
=
value
;
array
[
insertion_
index
]
=
value
;
*
array_length
+=
1
;
return
index
;
return
insertion_
index
;
}
void
sorted_array_delete
(
int
*
array
,
int
*
array_length
,
int
value
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment