MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Merge

Method Merge

structure/tree/btree.go:219–228  ·  view source on GitHub ↗

Transform: A B C / \ a b Into: A C | a B c

(idx int)

Source from the content-addressed store, hash-verified

217//
218// a B c
219func (node *BTreeNode[T]) Merge(idx int) {
220 if node.isLeaf {
221 panic("cannot merge when leaf node is parent")
222 }
223 left := node.children[idx]
224 right := node.children[idx+1]
225 left.Append(node.keys[idx], right.children[0])
226 left.Concat(right, 0)
227 node.DeleteIthKey(idx)
228}
229
230func (node *BTreeNode[T]) Min() T {
231 if node.isLeaf {

Callers 1

DeleteMethod · 0.95

Calls 3

DeleteIthKeyMethod · 0.95
AppendMethod · 0.80
ConcatMethod · 0.80

Tested by

no test coverage detected