Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 3rd, 2003, 11:50 AM
Wizard2003's Avatar
Wizard2003 Wizard2003 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 206 Wizard2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 29 m 24 sec
Reputation Power: 6
Algorithm to compare two trees

Hello all,

does anyone know a algorithm to compare two trees?
I heard something about the Levenshtein algorithm but I can't find anything about it.
Can someone help me?

Reply With Quote
  #2  
Old July 4th, 2003, 02:49 AM
majesty's Avatar
majesty majesty is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 3 majesty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to majesty
Depends what sort of tree you're referring to
And what exactly do u wanna compare?

Reply With Quote
  #3  
Old July 4th, 2003, 02:46 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 185
Itīs probably not the most effective way, but you could recursively traverse both trees and compare the value of each single node (assuming they are trees that can be read completely recursively). As soon as one differs, stop and return false.

More details, plz?
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #4  
Old July 4th, 2003, 06:31 PM
Wizard2003's Avatar
Wizard2003 Wizard2003 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 206 Wizard2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 29 m 24 sec
Reputation Power: 6
I want to compare two xml files (tree structure).
The problem is that the one tree don't need to have the same structure like the other. The structure can differ in some cases.
The rusult of the comparison should be a information about:
which nodes of the to trees are equal and at the same position in the trees
which nodes are equal but at different positions
which nodes are just in the one file
and which nodes are just in the other file
The node should be compared by the vlalues of their attributes

I've no idea how to realize this :-(

Reply With Quote
  #5  
Old July 5th, 2003, 02:18 AM
majesty's Avatar
majesty majesty is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 3 majesty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to majesty
Hmm i have no idea.. but pseudocode for checking structure of two trees such as a binary tree would be as follows

Code:
checksame(tree1,tree2)
    if(t1 is empty AND t2 is empty)
                return true
    if(t1 is empty OR t2 is empty)
               return false
    return true AND checksame(t1.right,t2.left) AND checksame(t2.left,t2.right)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Algorithm to compare two trees


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT