0

I'm implement a hashing table using ArrayList and LinkedList as bucket.

ArrayList<LinkedList<node>> db = new ArrayList<LinkedList<node>>();

How can I add new element in this ArrayList. Would it be something like this?

this.db.add(hash, element);

2 Answers 2

1

It works like this:

LinkedList<node> tmp = new LinkedList<node>();
tmp.add(new node());
this.db.add(tmp);
Sign up to request clarification or add additional context in comments.

Comments

1

It would be

db.get(hash).add(element);

of course requiring that your buckets (LinkedLists) have been instantiated already.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.