Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f94fbc

Browse files
Hashtable and hashnode constructor
1 parent 0fb5eb5 commit 7f94fbc

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

‎bigOnotation.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ log([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
99

1010
// Linear runtime - Big O Notation: "O (n)"
1111
function logAll(array) {
12-
for (var i = 0; i < array.length; i++) {
12+
for (let i = 0; i < array.length; i++) {
1313
console.log(array[i]);
1414
}
1515
}
@@ -20,8 +20,8 @@ logAll([1, 2, 3, 4, 5, 6, 7]);
2020

2121
// Exponential runtime - Big O Notation: "O (n^2)"
2222
function addAndLog(array) {
23-
for (var i = 0; i < array.length; i++) {
24-
for (var j = 0; j < array.length; j++) {
23+
for (let i = 0; i < array.length; i++) {
24+
for (let j = 0; j < array.length; j++) {
2525
console.log(array[i] + array[j]);
2626
}
2727
}
@@ -33,10 +33,10 @@ addAndLog(["A", "B", "C", "D", "E"]); // 25 pairs logged out
3333

3434
// Logarithmic runtime - Big O Notation: O (log n)
3535
function binarySearch(array, key) {
36-
var low = 0;
37-
var high = array.length - 1;
38-
var mid;
39-
var element;
36+
let low = 0;
37+
let high = array.length - 1;
38+
let mid;
39+
let element;
4040

4141
while (low <= high) {
4242
mid = Math.floor((low + high) / 2, 10);

‎hashTable.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function HashTable(size) {
2+
this.buckets = Array(size);
3+
this.numBuckets = this.buckets.length;
4+
}
5+
6+
function HashNode(key, value, next) {
7+
this.key = key;
8+
this.value = value;
9+
this.next = next || null;
10+
}
11+
12+
let myHT = new HashTable(10);
13+
console.log(myHT);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /