Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

is there implementation for b_tree indexing in file structure and organization in c++?

For Example, Consider the following Insertions: Insert: 3, 12
Insert: 7, 24 Insert: 10, 48 Insert: 24, 60 Insert: 14, 72

The index file should look as follow: -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 3 12 7 24 10 48 14 72 24 60 -1 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

After the previous insertions, Node 1 is a leaf node and all the references in it are pointing to records on data file.

Consider the following Insertion:

The index file should look as follow: -1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 10 2 24 3 -1 -1 -1 -1 -1 -1 0 3 12 7 24 10 48 -1 -1 -1 -1 0 14 72 19 84 24 60 -1 -1 -1 -1 -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

After the previous insertions, Node 1 is a non-leaf node and all the references in it are pointing to other nodes on the index file. Consider the following Insertions: Insert: 30, 96
Insert: 15, 108 Insert: 1, 120

The index file should look as follow: -1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 10 2 30 3 -1 -1 -1 -1 -1 -1 0 1 120 3 12 5 132 7 24 10 48 0 14 72 15 108 19 84 24 60 30 196 -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following Insertion:

The index file should look as follow: -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 3 2 10 4 30 3 -1 -1 -1 -1 0 1 120 2 144 3 12 -1 -1 -1 -1 0 14 72 15 108 19 84 24 60 30 196 0 5 132 7 24 10 48 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertions: Insert: 8, 156 Insert: 9, 168

-1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 3 2 10 4 30 3 -1 -1 -1 -1 0 1 120 2 144 3 12 -1 -1 -1 -1 0 14 72 15 108 19 84 24 60 30 196 0 5 132 7 24 8 156 9 168 10 48 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertion:

The index file should look as follow:
-1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 5 2 10 4 30 3 -1 -1 -1 -1 0 1 120 2 144 3 12 5 132 -1 -1 0 14 72 15 108 19 84 24 60 30 196 0 6 180 7 24 8 156 9 168 10 48 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertion:

-1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 5 2 10 4 30 3 -1 -1 -1 -1 0 1 120 2 144 3 12 4 192 5 132 0 14 72 15 108 19 84 24 60 30 196 0 6 180 7 24 8 156 9 168 10 48 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertion: Insert: 11, 204 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 5 2 10 4 15 3 30 5 -1 -1 0 1 120 2 144 3 12 4 192 5 132 0 11 204 14 72 15 108 -1 -1 -1 -1 0 6 180 7 24 8 156 9 168 10 48 0 19 84 24 60 30 196 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertions: Insert: 12, 216 Insert: 13, 228 Insert: 17, 240

-1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 5 2 10 4 15 3 30 5 -1 -1 0 1 120 2 144 3 12 4 192 5 132 0 11 204 12 216 13 228 14 72 15 108 0 6 180 7 24 8 156 9 168 10 48 0 17 240 18 252 19 84 24 60 30 196 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertion: Insert: 16, 264

The index file should look as follow:
-1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 5 2 10 4 15 3 18 5 30 6 0 1 120 2 144 3 12 4 192 5 132 0 11 204 12 216 13 228 14 72 15 108 0 6 180 7 24 8 156 9 168 10 48 0 16 264 17 240 18 252 -1 -1 -1 -1 0 19 84 24 60 30 196 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Consider the following insertion: Insert: 0, 276

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 10 8 30 9 -1 -1 -1 -1 -1 -1 0 0 276 1 120 2 144 -1 -1 -1 -1 0 11 204 12 216 13 228 14 72 15 108 0 6 180 7 24 8 156 9 168 10 48 0 16 264 17 240 18 252 -1 -1 -1 -1 0 19 84 24 60 30 196 -1 -1 -1 -1 0 3 12 4 192 5 132 -1 -1 -1 -1 1 2 2 5 7 10 4 -1 -1 -1 -1 1 15 3 18 5 30 6 -1 -1 -1 -1

question from:https://stackoverflow.com/questions/65832060/is-there-implementation-for-b-tree-indexing-in-file-structure-and-organization-i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...