<p>Hi,<br>
After a lot of brainstorming I found the problem in the implementation, which does not correctly handles the case when some nearSet elements are left (the while loop in create children: while(nearSet &gt; 0)). I have thought of a solution to correct it.<br>
It is based on the fact (which I would request you to confirm as well) that whenever a child node is created and childNearSet size and childFarSetSize are sent, the childNearSet will always be used (again the while condition: while(nearSet &gt; 0)). The remaining nodes (which obviously belong to childFarSetSize) can redistributed to our near and far sets, so that we can continue properly executing the creation of tree.<br>
To implement the changes we will need to update the SplitNearFarSet and PruneFarSet function, and create a new function that will put the remaining nodes in proper position.<br>
Once correctly implemented the implementation of cover tree won't require and extra memory for childIndices and childDistances and any unnecessary memory movement will be reduced.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/624#issuecomment-211138406">view it on GitHub</a><img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFJN44V4enz_f65ELZ28vyCrxmhZOks5p4s_4gaJpZM4IJBsx.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/624#issuecomment-211138406"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>