Skip to content

A problem about node split #3

@phac123

Description

@phac123

In the file 'B-Tree.py'.
There are some code problem.
Details are as follows.
In function '_splitChild(self, x, i)',

t = self.t
        y = x.children[i]
        z = Node(y.leaf)
        x.children.insert(i + 1, z)
        x.keys.insert(i, y.keys[t - 1])
        z.keys = y.keys[t: (2 * t) - 1]
        y.keys = y.keys[0: t - 1]
        if not y.leaf:
            z.children = y.children[t: 2 * t]
            y.children = y.children[0: t - 1]

In my view, the correct version is:
z.keys = y.keys[t:(2t)-1]; y.keys = y.keys[0:t-2]
z.children=y.children[t:2
t];y.children=y.children[0:t-1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions