class Node2 { int data; Node2 left; Node2 right; public Node2(int data, Node2 left, Node2 right) { this.data = data; this.left = left; this.right = right; } } class BinarySearchTree2 { Node2 head; public BinarySearchTree2(int data) { this.head = new Node2(data, null, null); } public Node2 addNodeRecursive(Node2 cur, int data) { if (cur == null) { return new Node2(data, null, null); } if (data < ..
자료구조 & 알고리즘/이진탐색트리
class Node { int data; Node left; Node right; public Node(int data, Node left, Node right) { this.data = data; this.left = left; this.right = right; } } class BinarySearchTree { Node head; public BinarySearchTree(int data) { this.head = new Node(data, null, null); } public void addNode(int data) { Node cur = this.head; Node parent = cur; while (cur != null) { if (data == cur.data) { System.out.p..