(BiNode root)
| 3 | public class QuestionB { |
| 4 | static int count = 0; |
| 5 | public static BiNode convert(BiNode root) { |
| 6 | if (root == null) { |
| 7 | return null; |
| 8 | } |
| 9 | |
| 10 | BiNode part1 = convert(root.node1); |
| 11 | BiNode part2 = convert(root.node2); |
| 12 | |
| 13 | if (part1 != null) { |
| 14 | concat(getTail(part1), root); |
| 15 | } |
| 16 | |
| 17 | if (part2 != null) { |
| 18 | concat(root, part2); |
| 19 | } |
| 20 | |
| 21 | return part1 == null ? root : part1; |
| 22 | } |
| 23 | |
| 24 | public static BiNode getTail(BiNode node) { |
| 25 | if (node == null) { |