Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Test the equivalence of two binary trees

Started 1 month, 1 week ago by MindstorM
I want to make a java code which tests the equivalence of two binary trees . For trivial cases (tree size 0,1, ...) the code seems pretty obvious. However when the size is increasing, I can not determine an algorithm that returns me the correct results. Could you help me find this algo so that I can continue to code? Or give me links? On google I did not really find what I want by ...
Site: TechArena Community - Technology and Computer Hardware Support Forums of India  TechArena Community - Technology and Computer Hardware Support Forums of India - site profile
Forum: Software Development  Software Development - forum profile
Total authors: 2 authors
Total thread posts: 13 posts
Thread activity: no new posts during last week
Domain info for: techarena.in

Other posts in this thread:

MindstorM replied 1 month, 1 week ago
In fact I have an expression such as E1 = -(A+B)*(C+D)/(C-D) E2 = (A*C + A*D + B*C + B*D) / (D – C) I have to build two trees with and create a method that determines if two trees are equivalent. For example A1.isEqual(Tree A2) should return true in this case.

fellah replied 1 month, 1 week ago
When you say equity, you mean full equality, the 2 trees and structurally identical data? If so this should be a recursive algorithm in this style: Code: boolean estEgal(Node node1, Node node2) { if(node1 == null) { return (node2 == null); } if(node2 == null) { return false; } return (node1.value == node2.value) && isEqual(node1....

fellah replied 1 month, 1 week ago
OK but it does not answer my questions: 1) How does your binary tree represents these formulas? What is their in the leaves? 2) What is the definition of "equivalent"?

fellah replied 1 month, 1 week ago
So nodes contain operations and leaves contain constants. Already, it allows multiple representations of the same formula. In fact this representation form of binary tree is more suitable for RPN(Reverse Polish Notation). For me two binary trees are equivalent to two trees that contain exactly the same elements, but that does not respond to your statement (refer to the true representation ...

MindstorM replied 1 month, 1 week ago
For E1 = -(A+B)*(C+D)/(C-D), for example, was this (sorry for the layout, this thing is capricious): Code: (*) / \ (-) (/) / / \ (+) (+) (+) / \ / \ / \ A B C D C D And just for the definition! Nothing in my course! Not to mention google

MindstorM replied 1 month, 1 week ago
In fact I have an expression such as E1 = -(A+B)*(C+D)/(C-D) E2 = (A*C + A*D + B*C + B*D) / (D ? C) I have to build two trees with and create a method that determines if two trees are equivalent. For example A1.isEqual(Tree A2) should return true in this case.

MindstorM replied 1 month, 1 week ago
I want to make a java code which tests the equivalence of two binary trees . For trivial cases (tree size 0,1, ...) the code seems pretty obvious. However when the size is increasing, I can not determine an algorithm that returns me the correct results. Could you help me find this algo so that I can continue to code? Or give me links? On google I did not really find what I want by ...

fellah replied 1 month, 1 week ago
When you say equity, you mean full equality, the 2 trees and structurally identical data? If so this should be a recursive algorithm in this style: Code: boolean estEgal(Node node1, Node node2) { if(node1 == null) { return (node2 == null); } if(node2 == null) { return false; } return (node1.value == node2.value) && isEqual(node1....

fellah replied 1 month, 1 week ago
OK but it does not answer my questions: 1) How does your binary tree represents these formulas? What is their in the leaves? 2) What is the definition of "equivalent"?

MindstorM replied 1 month, 1 week ago
For E1 = -(A+B)*(C+D)/(C-D), for example, was this (sorry for the layout, this thing is capricious): Code: (*) / \ (-) (/) / / \ (+) (+) (+) / \ / \ / \ A B C D C D And just for the definition! Nothing in my course! Not to mention google

 

Top contributing authors

Name
Posts
MindstorM
7
user's latest post:
Test the equivalence of two...
Published (2009-11-06 04:08:00)
I want to make a java code which tests the equivalence of two binary trees . For trivial cases (tree size 0,1, ...) the code seems pretty obvious. However when the size is increasing, I can not determine an algorithm that returns me the correct results. Could you help me find this algo so that I can continue to code? Or give me links? On google I did not really find what I want by searching this algo.
fellah
6
user's latest post:
Test the equivalence of two...
Published (2009-11-06 04:08:00)
When you say equity, you mean full equality, the 2 trees and structurally identical data? If so this should be a recursive algorithm in this style: Code: boolean estEgal(Node node1, Node node2) { if(node1 == null) { return (node2 == null); } if(node2 == null) { return false; } return (node1.value == node2.value) && isEqual(node1.childLeft, node2.childLeft) && isEqual(node1.childRight, node2.childRight); } And...

Related threads on "TechArena Community - Technology and Computer Hardware Support Forums of India":

Related threads on other sites:

Thread profile page for "Test the equivalence of two binary trees" on http://www.techarena.in. This report page is a snippet summary view from a single thread "Test the equivalence of two binary trees", located on the Message Board at http://www.techarena.in. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity