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

Method convert

java/Chapter 17/Question17_13/QuestionB.java:5–22  ·  view source on GitHub ↗
(BiNode root)

Source from the content-addressed store, hash-verified

3public 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) {

Callers 1

mainMethod · 0.95

Calls 2

concatMethod · 0.95
getTailMethod · 0.95

Tested by

no test coverage detected