-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Small code errors for the LinkedList and HashTable data structures #1033
Comments
I can do this , can you assign this to me |
Hello ..Its SSOC Contributor .I can easily do this . |
For the delete(value) {
if (!this.head) {
return;
}
if (this.compare.equal(this.head.value, value)) {
this.head = this.head.next;
return;
}
let current = this.head;
while (current.next) {
if (this.compare.equal(current.next.value, value)) {
current.next = current.next.next;
return;
}
current = current.next;
}
} For the constructor(hashTableSize) {
this.buckets = new Array(hashTableSize).fill(null).map(() => new LinkedList());
this.keys = {};
} |
Hello!
As I went through the code for these data structures, I noticed two small errors:
inside the
delete()
method of theLinkedList
data structure, there is a line of code that says:while (this.head && this.compare.equal(this.head.value, value))
. However, instead of awhile
it should be anif
statement.inside the
constructor()
of theHashTable
data structure, we initialize an array in the following way:this.buckets = Array(hashTableSize).fill(null).map(() => new LinkedList());
. However, theArray()
constructor should have thenew
keyword in front of it.If you guys feel that these are important fixes to you and if you allow me to help, I would be more than glad to contribute by creating a pull request with the changes made.
The text was updated successfully, but these errors were encountered: