fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3. //
  4. }
  5. private class Node<E> {
  6. private Node<E> root = null;
  7. private Node(E element) {
  8. balance(root);
  9. }
  10. private void add(Node<E> n, E element) {
  11. Node<E> e = new Node<E>(element);
  12. if (n == null)
  13. root = e;
  14. else if (n.compareTo(e) > 0)
  15. if (n.hasLeft())
  16. add(n.getLeft(), element);
  17. else
  18. n.setLeft(e);
  19. else if (n.hasRight())
  20. add(n.getRight(), element);
  21. else
  22. n.setRight(e);
  23. balance(e);
  24. }
  25. public int compareTo(Node<E> e) {
  26. return 0;
  27. }
  28. private Node<E> getLeft() {
  29. return null;
  30. }
  31. private Node<E> getRight() {
  32. return null;
  33. }
  34. private boolean hasLeft() {
  35. return true;
  36. }
  37. private boolean hasRight() {
  38. return true;
  39. }
  40. private void setLeft(Node<E> e) {
  41. }
  42. private void setRight(Node<E> e) {
  43. }
  44. private void balance(Node<E> e) {
  45. }
  46. }
  47. }
  48.  
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
Standard output is empty