public class Tree { private class Node { private int value; private Node[] nodes = new Node[4]; public Node() { } public Node(int v) { this.value = v; } public Node getNode(int poz) { return this.nodes[poz]; } public void setNode(int poz, int v) { this.nodes[poz] = new Node(v); } public void setValue(int v) { this.value = v; } public int getValue() { return this.value; } public void insert(int v, int delj) { int ost = delj%4; delj = delj/4; if ( delj == 0) delj = v; if ( this.nodes[ost] == null) { this.nodes[ost] = new Node(v); } else { this.nodes[ost].insert(v, delj); } } // preveri ali ima node otroke public boolean hasChilds() { for (int i = 0; i < 4; i++) { if ( this.nodes[i] != null ) return true; } return false; } } private Node root; public Tree() {} public void insert(int i) { if ( this.root == null) { root = new Node(i); return; } this.root.insert(i, i); }}