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; } // 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; } Node n = this.root; int ost, delj = i; while (true) { ost = delj%4; delj = delj/4; if ( delj == 0) delj = i; if ( n.getNode(ost) == null) { n.setNode(ost, i); return; } else { n = n.getNode(ost); } } }}