[英]2,4 tree with the fewest number of nodes with the given keys
suppose we have a set of keys K = {1, 2, 3, 4, 5, 6,..., 15} and we need to build a two four tree out of this such that:假设我们有一组键 K = {1, 2, 3, 4, 5, 6,..., 15} 我们需要从中构建一个二四树,这样:
my idea -我的想法-
a node in the two four tree can have upto 3 keys and 4 children per node, if we need to minimise the number of nodes we need to keep the nodes full as much as possible, but do not seem to be able to find a strategy that will guarantee this.二四树中的一个节点最多可以有3个键,每个节点有4个子节点,如果我们需要最小化节点数我们需要尽可能的保持节点满,但是好像找不到策略这将保证这一点。
one way that seemed lucrative was to split the array into three parts and then insert the medians at the root, next the first and the last child are pre-determined and repeat the same process for the rest of the remaining keys.this method also seems to fall short.一种似乎有利可图的方法是将数组分成三部分,然后在根部插入中位数,接下来第一个和最后一个孩子是预先确定的,并对剩余键的 rest 重复相同的过程。这种方法似乎也达不到要求。
we do know that the worst case height for such a structure needs to be near 4 and the best case height to be near 2 (using the 2, 4 tree height properties h ~ log(n))我们确实知道这种结构的最坏情况高度需要接近 4,最佳情况高度需要接近 2(使用 2、4 树高度属性 h ~ log(n))
is there any strategy to approach such problem (any hint would be appreciated)?是否有解决此类问题的策略(任何提示将不胜感激)?
To make a 2-4 tree with the smallest number of nodes:要制作节点数最少的 2-4 树:
So starting with 15 keys, you have 12 leaf-level keys in 4 nodes (3 parents).因此,从 15 个键开始,您在 4 个节点(3 个父节点)中有 12 个叶级键。 Those 3 parents can go in the root.
这 3 个父母可以 go 在 root 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.