Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the first thing you should think about is maybe going away from the N-Tree and going to as Binary Search tree.</p> <p>This means that all nodes have only 2 children, a greater child, and a lesser child.</p> <p>From there, I would say look into balancing your search tree with something like a Red-Black tree or AVL. That way, searching your tree is O(log n).</p> <p>Here are some links to get you started:</p> <p><a href="http://en.wikipedia.org/wiki/Binary_search_tree" rel="nofollow">http://en.wikipedia.org/wiki/Binary_search_tree</a> http://en.wikipedia.org/wiki/AVL_tree <a href="http://en.wikipedia.org/wiki/Red-black_tree" rel="nofollow">http://en.wikipedia.org/wiki/Red-black_tree</a></p> <p>Now, if you are dead set on having each node able to have N child nodes, here are some things you should thing about:</p> <ol> <li>Think about ordering your child nodes so that you can quickly determine which has the highest leaf number. that way, when you enter a new node, you can check one child node and quickly determine if it is worth recursively checking it's children.</li> <li>Think about ways that you can quickly eliminate as many nodes as you possibly can from the search or break the recursive calls as early as you can. With the binary search tree, you can easily find the largest leaf node by always only looking at the greater child. this could eliminate <code>N-log(n)</code> children if the tree is balanced.</li> <li>Think about inserting and deleting nodes. If you spend more time here, you could save a lot more time later</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload