Уже сделал проверку всего, что только возможно. Не хочу смотреть в готовое решение, хочу разобраться.
![]()

package com.javarush.task.task20.task2028;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
CustomTree list = new CustomTree();
for (int i = 1; i < 200; i++) {
list.add(String.valueOf(i));
}
String parent;
String Lchild;
String Rchild;
for (CustomTree.Entry<String> entry: list.entries) {
if (entry.parent != null) {
parent = entry.parent.elementName;
} else{
parent = "null";
}
if (entry.leftChild != null) {
Lchild = entry.leftChild.elementName;
} else{
Lchild = "null";
}
if (entry.rightChild != null) {
Rchild = entry.rightChild.elementName;
} else{
Rchild = "null";
}
System.out.println("Name: " + entry.elementName + ", Level: " +
entry.elementLevel + ", Parent: " +
parent + ", L_child: " +
Lchild + ", R_child: " +
Rchild);
}
System.out.println("Elements on each level " + Arrays.toString(list.countOfElementsOnLevel));
System.out.println("The list size is " + list.size());
System.out.println("The expected parent is 3. The actual parent is " + list.getParent("129"));
System.out.println("The expected parent is null. The actual parent is " + list.getParent("20"));
}
}

Произвольный порядок следования значений добавляемых узлов не влияет на их расположение в дереве.