Have a look at AVL Trees or Red-black trees. They are both types of self balancing trees which is what I think you're looking for. -- - Scott Kidder () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments