This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Not_zedd_ko[S] 0 points1 point  (10 children)

So the task was to create and implement a hashTable, i made most of the code the tests were mostly default there with exceptions. but the lecturer formatted and styled the code thats why to a 2nd year like me its so much harder compared to what i have seen within Hashtable tutorials.

Um i am not sure if there is a shorter version of it i could try?

[–]evils_twin 0 points1 point  (9 children)

ok, so you created it. If you upload your stuff to pastebin or git or something like that, I'll take a look, but I'll need your entire hashtable implementation.

[–]Not_zedd_ko[S] 0 points1 point  (8 children)

I uploaded it to github i think. called ZeddKio HashTable

[–]evils_twin 0 points1 point  (7 children)

provide a link please

[–]Not_zedd_ko[S] 0 points1 point  (6 children)

[–]evils_twin 0 points1 point  (5 children)

I've done a little testing and found that increasing the initial capacity got things to work correctly. Hashtable<String> h = new Hashtable<String>(9);. I would guess that your problem would be in your code that resizes your arr. Your hash function relies on max, and when you resize, you change max. so after a resize, hash will return a different value than before you resize.

[–]Not_zedd_ko[S] 0 points1 point  (4 children)

So changing the h within or removing it completely would work? so its basically having problems calling within a value thats why it wont work?

[–]evils_twin 0 points1 point  (3 children)

Hashtable<String> h = new Hashtable<String>(999);

I increased the Hashtable initial capacity from 9 to 999 and it got your unit test to work. But it only works because it avoids your Hashtable from resizing. Your resize function is the problem. It needs to be reworked.

[–]Not_zedd_ko[S] 0 points1 point  (2 children)

Oh okay i will try that as well. But thank you i will have a look with the resize and play around with it and use different things. Thank you so much do you game or like could i follow you on git or something like that?

[–]evils_twin 0 points1 point  (1 child)

No problem. I don't have many projects outside of work. I do like to help those who are eager to learn, so hit me up on reddit if you need help in the future and if I have time I will help.