The Wayback Machine - https://web.archive.org/web/20201103185134/https://github.com/TheAlgorithms/Java/pull/1026
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created new hashing data structure #1026

Open
wants to merge 4 commits into
base: master
from

Conversation

@furahadamien
Copy link
Contributor

@furahadamien furahadamien commented Oct 11, 2019

created a new data structure that uses open addressing for hashing. uses a quadratic hashing technique to generate the hash key

protected Open_Addressing(int index, int seed) {
this.index = index;
this.hasher = (int) (index - 1) / 2 + 1;
this.tableSize = power2(hasher);

This comment has been minimized.

@yanglbme

yanglbme Oct 12, 2019
Member

where's the method power2() ?

This comment has been minimized.

@furahadamien

furahadamien Oct 12, 2019
Author Contributor

I had forgotten the function in my first commit. Now added

* the Open_Addressing object uses an array for hashing
* using quadratic hashing, we make it possible to add an element and retrieve its value from the array in constant time
*/
public class Open_Addressing {

This comment has been minimized.

@yanglbme

yanglbme Oct 12, 2019
Member

It should be OpenAddressing, not Open_Addressing.

This comment has been minimized.

@furahadamien

furahadamien Oct 12, 2019
Author Contributor

Changed the name in my second commit

/**
* Calculate 2^index
*/
public static int power2(int index) {
return (int) Math.pow(2, index);
}
Comment on lines +106 to +111

This comment has been minimized.

@furahadamien

furahadamien Oct 12, 2019
Author Contributor

added the power function that was requested

public class Open_Addressing {
public class OpenAddressing {
Comment on lines 6 to 6

This comment has been minimized.

@furahadamien

furahadamien Oct 12, 2019
Author Contributor

renamed the class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.