I can not find my mistake in AHU algorithm to detect if two trees are isomorphic

206 Views Asked by At

I am using AHU algorithm to detect if two rooted trees are isomorphic or not, and I used this algorithm, I have sent it to my teacher and my teacher put a comment that there is a mistake in this algorithm according to your example of trees, but I can not see where is my mistake?

you see the small yellow box it the image? that's the comment

enter image description here

and this is the example according to the image, in this part, I am supposed to assign tuples in the form of parentheses to the leaves of trees and from button to up to the root it gets children's parentheses

enter image description here

now I have to convert these parentheses to numbers, so I could obtain the canonical numbers of a tree... and then sort the number so for each tree I could have a unique number and compare these two numbers between then tree to check if they are similar or not

enter image description here

enter image description here

Here I have sorted the algorithm

enter image description here and here is the algorithm for converting the parentheses to numbers, but the thing I do not see is from my perspective this algorithm matches with the examples I have provided, but as you see in the first image, the little yellow box is the comment I have gotten from teacher that "there is a mistake here", and I don't know what is it

What do you think is my mistake?