V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
helloworld12
V2EX  ›  算法

B 树根节点,是否也同时可以当做叶子节点

  •  
  •   helloworld12 · Mar 5, 2017 · 4068 views
    This topic created in 3339 days ago, the information mentioned may be changed or developed.

    如题。 B 树的根节点,是否同时可以当做叶节点,还是必须有中间节点

    我准备用 golang 实现一个 B 树
    我先前是假设根节点,也可以当做叶子节点,然后在要分裂的时候就懵逼了,不知道该怎么分裂出中间节点

    type BTNode struct {
        keys   []int
        vals   []interface{}
        isLeaf  bool
        parentNode *BTNode
    }
    
    1 replies    2017-03-05 20:04:37 +08:00
    helloworld12
        1
    helloworld12  
    OP
       Mar 5, 2017
    看 btree 实现的时候,有个不懂得,为什么 [New(2) 得到的是一个 234 树]( https://github.com/google/btree/blob/master/btree.go#L119-L125) 不应该是 2 个叉都是 2 个 key3 个子元素吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6145 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 06:20 · PVG 14:20 · LAX 23:20 · JFK 02:20
    ♥ Do have faith in what you're doing.