MCPcopy Create free account
hub / github.com/careercup/ctci / convert

Method convert

java/Chapter 17/Question17_13/QuestionA.java:14–31  ·  view source on GitHub ↗
(BiNode root)

Source from the content-addressed store, hash-verified

12 }
13
14 public static NodePair convert(BiNode root) {
15 if (root == null) {
16 return null;
17 }
18
19 NodePair part1 = convert(root.node1);
20 NodePair part2 = convert(root.node2);
21
22 if (part1 != null) {
23 concat(part1.tail, root);
24 }
25
26 if (part2 != null) {
27 concat(root, part2.head);
28 }
29
30 return new NodePair(part1 == null ? root : part1.head, part2 == null ? root : part2.tail);
31 }
32
33 public static void concat(BiNode x, BiNode y) {
34 x.node2 = y;

Callers 1

mainMethod · 0.95

Calls 1

concatMethod · 0.95

Tested by

no test coverage detected