数组树...也许递归?
我正在尝试递归地划分数组...我认为这就是所谓的哈哈...
例如,假设初始数组包含 50 个值,最高为 97,最低为 7...我想将该数组分成两部分,根据它们是否大于或小于整个集合的中间范围来划分它们。中频为 52...( (97+7)/2 ) 然后我想使用相同的方法来划分这两个数组,等等,理想情况下有一个程序可以重复这个过程任意次数......
Load Values into array1
Find Midrange
For every value in array1{
if value > midrange{
assign value to ArrayHigh1}
Else{ assign value to ArrayLow1}
}
Perform same thing on ArrayHigh1 and ArrayHigh2
等等等等。
我很难弄清楚如何创建连续的数组数组(ArrayHigh2 3 4 等)
另外,我觉得必须有一种更简单的方法来做到这一点,但我现在想不出一个......
感谢您的帮助
I am trying to divide arrays recursively... I think that is what this would be called haha....
For instance, lets say the initial array contains 50 values the highest being 97 and the lowest being 7... I want to split this array into two, dividing them based on whether they are greater or lower than the midrange of the entire set. The midrange being 52...( (97+7)/2 )
Then I want to divide these two arrays using the same method and so on, ideally having a program that repeat this process an arbitrary number of times....
Load Values into array1
Find Midrange
For every value in array1{
if value > midrange{
assign value to ArrayHigh1}
Else{ assign value to ArrayLow1}
}
Perform same thing on ArrayHigh1 and ArrayHigh2
Etc etc etc.
I'm having trouble figuring out how I would create the successive arrays (ArrayHigh2 3 4 etc)
Also, I feel like there must be an easier way to do this, but I cannot think of one at the moment...
Thanks for the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎正在朝着 B-tree 或Merge- 或 快速排序。 大量参考实现是在线提供。
虽然一般而言,您可能会从阅读许多书籍中受益匪浅这里大家熟悉一下。
You seem to be working your way towards a B-tree or an implementation of Merge- or Quicksort. Plenty of reference implementations are available online.
Though speaking generally, you might benefit greatly from reading a book many here are familiar with.