Array+Binary Tree+ HashTable

Hey,
I have to implements a program which will take two lists of strings and the strings of the first list should be placed in an UNORDERED array, to an ordered tree and to a hashTable.
and then each word in the second list should be checked if it is contained in the unordered array, binary tree, hashtable.

Can anyone give me a clue how to start this program ?? [ or if its something already made it should be much better :p]

thanks in advance !
perdoname_Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gatorvipCommented:
where is the difficulty?

If I'm interpreting your post correctly, you will insert the contents of the first list into 3 different data structures, so...

-your unordered array will have the same length as the first list of strings
-loop through the list, and at each step add the current string into the array, the BT and the hashtable.
0
perdoname_Author Commented:
thats what i did up to now :/
import java.util.*;
 
public class ArrayTreeHash 
{
 
 
    
    //unordered array
   // class UnorderedArrayList
   // {
        
     //   var unorderedArr: Array = new Arry();
   // }
        
    //binary tree
 
 
 
 
 
class TreeNode {
 
    String data;
    TreeNode left;   
    TreeNode right;   
 
 
 
 
   
} 
 
 
 
public class BinaryTreeString {
 
    TreeNode root = null;    
    int numItems = 0;        
 
    public void add (String data)
    {
 
        if (root == null) {
            root = new TreeNode ();
            root.data = data;
            numItems ++;
            return;
        }
        
 
        if ( contains (data) ) {
 
            return;
        }
        
 
        recursiveInsert (root, data);
        
        numItems ++;
    }
 
    
    void recursiveInsert (TreeNode node, String data)
    {
 
        if ( data.compareTo (node.data) < 0 ) {
 
            if (node.left != null) {
                recursiveInsert (node.left, data);
            }
            else {
                node.left = new TreeNode ();
                node.left.data = data;
            }
            
        }
 
        else {
 
            if (node.right != null) {
                recursiveInsert (node.right, data);
            }
            else {
                node.right = new TreeNode ();
                node.right.data = data;
            }
        }
        
    }
    
    
    //hashTable
    class HashTable
    {
        Map<String, list1> data = new HasMap<String, list1>();
        
    }
}
}
 
 
 
class BinaryTreeStringExample 
//extends ArrayTreeHash {
{
 
    public static void main (String[] argv)
    {
        String [] list1 = {"java","hello","fight"};
 
        BinaryTreeString tree = new BinaryTreeString ();
 
            //
            //
            
 
    }
 
}
   

Open in new window

0
gatorvipCommented:
from a general point of view, I would use 4 classes.

1. Entry class
- contains the 2 lists of strings
- constructs one instance of each class (Arr, BT, HT) based on the first list of strings
- creates a loop where in each iteration, you take the next word in the second list of strings. Then you call the method "has" in each of the other 3 instances (Arr, BT, HT) to see whether that word is contained in them

2. Array
- takes one parameter as input (list of strings), either in the constructor or in a helper method, and populates its internal fields based on that parameter
- contains one public method, let's call it   has(String s)  which returns true if the instance contains s
3. Binary Tree
- takes one parameter as input (list of strings), either in the constructor or in a helper method, and populates its internal fields based on that parameter
- contains one public method, let's call it   has(String s)  which returns true if the instance contains s
4. HashTable
- takes one parameter as input (list of strings), either in the constructor or in a helper method, and populates its internal fields based on that parameter
- contains one public method, let's call it   has(String s)  which returns true if the instance contains s
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.