Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package real;
- import java.util.ArrayList;
- import java.util.Collection;
- import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils.Collections;
- public class TreeSearch {
- private ArrayList<TreeNode> array[];
- private static int rear;
- public TreeSearch() {
- rear = 0;
- array = (ArrayList<TreeNode>[]) new ArrayList[26];
- for (int i = 0; i < 26; i++) {
- array[i] = new ArrayList<TreeNode>();
- }
- }
- public int getRoot() {
- return array[0].get(0).getItem();
- }
- public void ArrayInser(char letter){
- }
- public void insert(TreeNode node) {
- for (int i = 0; i < rear; i++) {
- for (int y = 0; y < array[i].size(); y++) {
- if (node == array[i].get(y)) {
- return;
- }
- }
- }
- array[rear].add(node);
- rear++;
- }
- public boolean isEmpty() {
- if (array[0] != null) {
- }
- return false;
- }
- public int size() {
- int size = 0;
- for (int i = 0; i < rear; i++)
- size += array[i].size();
- return size;
- }
- public String find(TreeNode node) {
- String result = "NOT_FOUND";
- for (int i = 0; i < rear; i++) {
- for (int y = 0; y < array[i].size(); y++) {
- if (node == array[i].get(y)) {
- result = i + " " + y;
- node.increase();
- }
- }
- }
- return result;
- }
- public String toString() {
- String result = "";
- for (int i = 0; i < rear; i++)
- for (int y = 0; y < array[i].size(); y++)
- result += array[i].get(y) ;
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement