### eidan's blog

By eidan, history, 3 years ago,

I was reading about tree isomorphism and came across this paper. It explains an amazing algorithm developed by Aho, Hopcroft and Ullman which finds out if two rooted trees are isomorphic in linear time. I have searched for this problem on several online judges in order to test my implementation, but have had no success. If anyone has seen a problem that requires this algorithm could he/she be so kind to share the link?

Any help is appreciated :)

• -3

 » 3 years ago, # |   +3 Something like that? Problem
•  » » 3 years ago, # ^ |   0 Thank you for sharing. However, that is not exactly what I am looking for. That problem requires checking if two binary trees are isomorphic. I have actually already tested this algorithm on that problem XD. But now I want to test if my implementation works on any type of rooted tree, not only binary.
•  » » » 3 years ago, # ^ |   0 I think it could help so Any type tree Problem
•  » » » » 3 years ago, # ^ |   0 That is a great example too. However, in that problem, the tree is not rooted.
•  » » » » » 3 years ago, # ^ |   +6 No, it doesn’t really matter. Can you see why? SpoilerSimply root by centroid. If there is two choice of centroid, then just brute force for 2*2 cases.
•  » » » » » » 6 weeks ago, # ^ |   0 Sorry for the possible necroposting, but there is a possible (but somewhat trivial) constant-optimization that can be done.If the numbers of centroids do not match, the trees are not isomorphic.If both have one centroid, it suffices to check after rooting by that centroid.If both have two centroids, then fix one centroid in one tree and check both centroids in the other tree.This gives a speed-up of about 2x in the worst-case :)
 » 3 years ago, # |   +10 This appeared in the Indian online regional — https://www.codechef.com/problems/TWOTREES
 » 3 years ago, # |   0
 » 7 weeks ago, # |   +13
 » 7 weeks ago, # |   0
 » 7 weeks ago, # |   +8 Hey,This one isn't rooted, but by using the technique ko_osaga mentioned above, it should be reducible into it anyway. It's from a recent ICPC Regional.Hope it helps!
•  » » 7 weeks ago, # ^ |   +5 Thankss ! I have long searched for something like this