Re: Nested Sets and custom sorting

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: --CELKO-- (jcelko212_at_earthlink.net)
Date: 08/05/04


Date: 4 Aug 2004 20:54:33 -0700

Here is the link on Amazon.com for my new book on "Trees & Hierarchies
in SQL"

http://www.amazon.com/exec/obidos/tg/detail/-/1558609202/qid=1080772873/sr=1-1/ref=sr_1_1/102-7683601-6345721?v=glance&s=books#product-details

I have routines for swapping siblings, inserting in any position, etc.
in the Nested set model, so you can give the tree whatever structure
you wish. The push-down stack tree traversal I give on the news
groups uses collation order on the sibling node ids -- leftmost son is
also the one with the minimum value.

>> In my case, the ordering of sub-nodes depends on the value of the
ListOrder and SortIndex fields of a node. And I can't find a good way
of inserting the nodes in the desired order without using nested
cursors or such. <<

The general idea is that given a new node that you wan to place under
a parent and between two existing siblings, you make a gap. The gap
is made by adding 2 to each lft and rgt values to the right of the
insertion point. Same idea for inserting a new subtree, but with a
bigger gap.

There are also routines for swapping sibling subtrees. I am in the
middle of packing for a move, so I cannot get to my manuscript
diskettes, but the swapping code has be posted in newsgroups.



Relevant Pages

  • Re: Discrete event simulation & AVL Tree
    ... > time advance and executing discrete events (i.e inserting and removing ... > events from the tree, depending on their execution time). ...
    (comp.simulation)
  • Re: Problems with dynamicall changing JTree
    ... aspa wrote: ... >> i guess your problem is not the custom node object but the way you add ... which is actually used by the tree. ... make sure your're inserting to the right parent. ...
    (comp.lang.java.gui)
  • Re: Worst case for inserting into a BST
    ... >) What the efficiency of inserting an item into a binary search tree in the ... >) My textbook says it's Obut another resource says that inserting an item ... That would be tree with an arbitrary binary tree. ...
    (comp.programming)
  • Re: tree problem
    ... > If I only inserting going by first digit it works properly but when I ... > Node is an IPAddress, portNumber, left pointer and right pointer ... implementation of the bits described and sometimes we need to compile ... the type of tree. ...
    (comp.lang.c)