-
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.

-
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:-)
-
dont know how to balance a tree, so i used arrays storing strings read from files!
-
huh? What's that got to do with comparing trees?
ArchAngel.
O:-)
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|