Java Visitor Pattern

  • + 0 comments

    The problem description is tricky and easily misleading. Specifically it says:

    ...Each of the subsequent lines contains two space-separated integers, *ui* and *vi* , describing an edge between nodes *u* and *v*.

    An edge input like this:

    3 4

    does not mean that 3 is the parent. The parent may as well be noted on the right side. The correct interpretation:

    There is just a link between 3 and 4, it's unspecified which one is tree node/leaf node.