in reply to Basic tree - compare question

I was assuming that greater values went to the right and lesser to the left (as all the pictures of sample trees in the book showed). Also made this assumtion when learning trees in one of my Data structure courses - and thats the order we built them. But as Grandfather says, either way would be ok as its hidden from the user.

I did build a tree just now (using the code from the book), and reversed the order to put greater values to the right and Data::Dumper showed me the structure I was looking for. Thanks for the tip on the Tree modules, Dragonchild. I'll give them a closer look tomorrow. If I do need to use them I will consider looking at these modules. I imagine being written in C, it may be faster and they have many features. However, I'm trying to re-learn what I had in school 8 years ago (water under the bridge :-)   ).

Thanks for the input everyone.

Replies are listed 'Best First'.
Re^2: Basic tree - compare question
by dragonchild (Archbishop) on Oct 09, 2007 at 12:08 UTC
    Tree and Tree::Simple aren't written in C - they're written in Perl. Very fast optimized Perl, but Perl nonetheless. THe C I was referring to was how the example code was structured.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?