Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP_Bplus_Tree
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
Show more breadcrumbs
Hepia_2021-2022
Prog_Seq
TP_Bplus_Tree
Commits
3fc3d0df
Commit
3fc3d0df
authored
3 years ago
by
Alec
Browse files
Options
Downloads
Patches
Plain Diff
modified print func
parent
6de38c99
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bp_tree.c
+6
-8
6 additions, 8 deletions
bp_tree.c
bp_tree.h
+1
-1
1 addition, 1 deletion
bp_tree.h
main.c
+38
-61
38 additions, 61 deletions
main.c
with
45 additions
and
70 deletions
bp_tree.c
+
6
−
8
View file @
3fc3d0df
...
@@ -261,13 +261,14 @@ void bp_print_as_ll(node *root)
...
@@ -261,13 +261,14 @@ void bp_print_as_ll(node *root)
return
bp_print_as_ll
(
root
->
childs
[
0
]);
return
bp_print_as_ll
(
root
->
childs
[
0
]);
}
}
printf
(
"|"
);
// print every values in the node until hitting 0, then we can get on the next node
// print every values in the node until hitting 0, then we can get on the next node
for
(
int
i
=
0
;
i
<
M
;
i
++
)
for
(
int
i
=
0
;
i
<
M
;
i
++
)
{
{
printf
(
" %d |"
,
root
->
data
[
i
]);
printf
(
" %d |"
,
root
->
data
[
i
]);
if
(
root
->
data
[
i
+
1
]
==
0
)
if
(
root
->
data
[
i
+
1
]
==
0
)
{
{
printf
(
"->"
);
printf
(
"
->
"
);
return
bp_print_as_ll
(
root
->
next
);
return
bp_print_as_ll
(
root
->
next
);
}
}
}
}
...
@@ -288,23 +289,20 @@ void bp_print(node *root, int depth)
...
@@ -288,23 +289,20 @@ void bp_print(node *root, int depth)
if
(
root
->
data
[
i
+
1
]
==
0
)
if
(
root
->
data
[
i
+
1
]
==
0
)
break
;
break
;
}
}
printf
(
"
\n
"
);
return
;
return
;
}
}
for
(
int
i
=
0
;
i
<
M
;
i
++
)
for
(
int
i
=
0
;
i
<
M
;
i
++
)
{
{
printf
(
"
\n
"
);
bp_print
(
root
->
childs
[
i
],
depth
+
1
);
bp_print
(
root
->
childs
[
i
],
depth
+
1
);
printf
(
"
\n
"
);
for
(
int
i
=
0
;
i
<
depth
;
i
++
)
for
(
int
i
=
0
;
i
<
depth
;
i
++
)
printf
(
" "
);
printf
(
" "
);
printf
(
" %d |"
,
root
->
data
[
i
]);
printf
(
" %d |
\n
"
,
root
->
data
[
i
]);
if
(
root
->
data
[
i
+
1
]
==
0
)
if
(
root
->
data
[
i
+
1
]
==
0
)
{
printf
(
"
\n
"
);
return
bp_print
(
root
->
childs
[
i
+
1
],
depth
+
1
);
return
bp_print
(
root
->
childs
[
i
+
1
],
depth
+
1
);
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bp_tree.h
+
1
−
1
View file @
3fc3d0df
#ifndef _BP_TREE_C_
#ifndef _BP_TREE_C_
#define _BP_TREE_C_
#define _BP_TREE_C_
#define M
5
#define M
4
#include
<stdlib.h>
#include
<stdlib.h>
typedef
struct
node
{
typedef
struct
node
{
...
...
This diff is collapsed.
Click to expand it.
main.c
+
38
−
61
View file @
3fc3d0df
#include
"bp_tree.h"
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
"bp_tree.h"
int
main
(){
/*
node *test = bp_create_node();
test->count = 1;
int
test->data[0] = 3;
main
()
for (int i = 0; i < 2; i++)
{
{
node
*
tree
=
bp_create_node
();
test->childs[i] = bp_create_node();
test->childs[i]->count = 1;
test->childs[i]->data[0] = 3;
for (int y = 0; y < 2; y++)
{
test->childs[i]->childs[y] = bp_create_node();
for (int z = 0; z < 2; z++)
{
test->childs[i]->childs[y]->data[z] = 3;
}
test->childs[i]->childs[y]->count = 2;
}
}
bp_print(test, 0);
bp_destroy(test);*/
node
*
tree
=
bp_create_node
();
tree
=
bp_insert_val
(
tree
,
3
);
tree
=
bp_insert_val
(
tree
,
3
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
6
);
tree
=
bp_insert_val
(
tree
,
6
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
5
);
tree
=
bp_insert_val
(
tree
,
5
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
4
);
tree
=
bp_insert_val
(
tree
,
4
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
7
);
tree
=
bp_insert_val
(
tree
,
7
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
8
);
tree
=
bp_insert_val
(
tree
,
8
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
9
);
tree
=
bp_insert_val
(
tree
,
9
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
10
);
tree
=
bp_insert_val
(
tree
,
10
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
11
);
tree
=
bp_insert_val
(
tree
,
11
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
printf
(
"|||||||||
\n
"
);
printf
(
"
\n
|||||||||
\n
"
);
tree
=
bp_insert_val
(
tree
,
12
);
tree
=
bp_insert_val
(
tree
,
12
);
bp_print
(
tree
,
0
);
bp_print
(
tree
,
0
);
bp_print_as_ll
(
tree
);
printf
(
"
\n
|||||||||
\n
"
);
bp_destroy
(
tree
);
bp_print_as_ll
(
tree
);
return
0
;
bp_destroy
(
tree
);
return
0
;
}
}
\ No newline at end of file
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