comparing trees


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: comparing trees

  1. #1
    Join Date
    Mar 2003
    Posts
    3

    comparing trees

    Hey,

    I have 2 BSTs containing strings - e.g. Tree1, Tree2.

    The strings in each tree are from an input file

    I want to check the contents of each tree, and if a string is in tree1, but not in tree2, i want to either add it, or alert the user.

    I'm not entirely sure how to compare the two trees. I've coded the trees correctly and inserted the files into them. My methods for adding/deleting/etc work. Comparing is the problem.

    Appreciate any help.


  2. #2
    Join Date
    Mar 2003
    Posts
    834

    Unhappy

    I always hated this data structure stuff. Can't you do an in-order traversal (but probably any type of traversal would do) and for each element in the tree search for its counterpart in the second tree?

    I've had thoughts about building a Set out of the second tree, but I imagine the tree would probably have quicker searching ability.

    ArchAngel.
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Mar 2003
    Posts
    3
    dont know how to balance a tree, so i used arrays storing strings read from files!

  4. #4
    Join Date
    Mar 2003
    Posts
    834
    huh? What's that got to do with comparing trees?
    ArchAngel.
    O:-)

  5. #5
    Join Date
    Mar 2003
    Posts
    3
    Originally posted by ArchAngel
    huh? What's that got to do with comparing trees?
    well...

    take an input file, read the strings from that into an array, insert the array into a tree...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center