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
94870ad9
Commit
94870ad9
authored
3 years ago
by
florian.burgener
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring
parent
b4f49d51
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
__main__.py
+14
-11
14 additions, 11 deletions
__main__.py
with
14 additions
and
11 deletions
__main__.py
+
14
−
11
View file @
94870ad9
...
@@ -37,18 +37,23 @@ def array_insert_sorted(array, value):
...
@@ -37,18 +37,23 @@ def array_insert_sorted(array, value):
return
index
return
index
def
insert
(
root
,
key
):
def
find_leaf
(
root
,
key
):
leaf_node
=
root
parents
=
[]
parents
=
[]
while
not
leaf_node
.
is_leaf
:
current
=
root
parents
.
append
(
leaf_node
)
while
not
current
.
is_leaf
:
index
=
array_binary_search
(
leaf_node
.
keys
,
key
)
parents
.
append
(
current
)
leaf_node
=
leaf_node
.
children
[
index
]
children_index
=
array_binary_search
(
current
.
keys
,
key
)
current
=
current
.
children
[
children_index
]
return
parents
,
current
def
insert
(
root
,
key
):
parents
,
leaf
=
find_leaf
(
root
,
key
)
if
node_is_full
(
leaf
_node
):
if
node_is_full
(
leaf
):
insert_full
(
root
,
parents
,
leaf
_node
,
key
,
None
)
insert_full
(
root
,
parents
,
leaf
,
key
,
None
)
else
:
else
:
insert_non_full
(
leaf
_node
,
key
,
None
)
insert_non_full
(
leaf
,
key
,
None
)
def
insert_non_full
(
node
,
key
,
right_child_node
):
def
insert_non_full
(
node
,
key
,
right_child_node
):
...
@@ -156,8 +161,6 @@ def increase_height(root, key, right_child_node):
...
@@ -156,8 +161,6 @@ def increase_height(root, key, right_child_node):
def
tree_print
(
root
,
depth
=
0
):
def
tree_print
(
root
,
depth
=
0
):
if
len
(
root
.
keys
)
==
0
:
return
print
(
"
"
*
depth
,
end
=
""
)
print
(
"
"
*
depth
,
end
=
""
)
print
(
root
.
keys
)
print
(
root
.
keys
)
...
...
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