- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
balance2N(nodeGet(0), nodeGet(0).getLine(0).getNodeConnectedWith(nodeGet(0)));
class Node {
private ArrayList<Line> children = new ArrayList<Line>();
public Line getLine (int index) {
return children.get(index);
}
}
class Line {
private Node[] parents = new Node[2];
public Node getNodeConnectedWith(Node nodeA) {
if (parents[0] == nodeA) {
return parents[1]; //return node another from this node (node on the other side)
} else { //if parents[1] == nodeA equals !(parents[0] == nodeA)
return parents[0];
}
}
}