Skip to content

Instantly share code, notes, and snippets.

View Marindala's full-sized avatar

Marina Marindala

View GitHub Profile
function hashStringToInt(s, tableSize) {
let hash = 17;
for (let i = 0; i < s.length; i++) {
hash = (13 * hash * s.charCodeAt(i)) % tableSize;
}
return hash;
}
@nickangtc
nickangtc / linked-list.js
Last active June 15, 2022 04:37
Linked list in JavaScript
/**
* Read the original blog post for a detailed explanation!
* http://www.nickang.com/linked-list-explained-part-1/
* http://www.nickang.com/linked-list-implementation-part-2/
*/
/**
* Constructor functions
*/
@rodrwan
rodrwan / binary-tree.js
Last active February 11, 2024 15:14
Implementación árbol binario en JavaScript
class Node {
constructor (value) {
this.value = value
this.right = null
this.left = null
}
}
class Tree {
constructor () {
@rebeccapeltz
rebeccapeltz / trees.js
Created May 29, 2017 17:14
Implementing a Binary Search Tree with utility in JavaScript
'use strict';
//https://gist.github.com/alexhawkins/f993569424789f3be5db
//http: //stackoverflow.com/questions/1331289/javascript-binary-search-tree-implementation
function BinarySearchTree(value) {
this.value = value;
this.left = null;
this.right = null;
}