Skip to content

Instantly share code, notes, and snippets.

View msuganthan's full-sized avatar
🎯
Focusing

Suganthan Madhavan msuganthan

🎯
Focusing
View GitHub Profile
static class BTreePrinter {
public static <T extends Comparable<?>> void printNode(Node root) {
int maxLevel = BTreePrinter.maxLevel(root);
printNodeInternal(Collections.singletonList(root), 1, maxLevel);
}
private static <T extends Comparable<?>> void printNodeInternal(List<Node> nodes, int level, int maxLevel) {
if (nodes.isEmpty() || BTreePrinter.isAllElementsNull(nodes))