Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trekhleb/javascript-algorithms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: linghuam/javascript-algorithms
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 4 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 12, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    30b8d84 View commit details
  2. Merge pull request #1 from linghuam/linghuam-patch-1

    some mistakes in delete method and time comlexity
    linghuam authored Mar 12, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8367ac1 View commit details

Commits on Mar 25, 2019

  1. fixbug

    孟令华 authored and 孟令华 committed Mar 25, 2019
    Copy the full SHA
    7b86db2 View commit details
  2. Merge branch 'master' of https://github.com/linghuam/javascript-algor…

    孟令华 authored and 孟令华 committed Mar 25, 2019
    Copy the full SHA
    8a52fb2 View commit details
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/data-structures/doubly-linked-list/README.md
  2. +2 −2 src/data-structures/hash-table/HashTable.js
4 changes: 2 additions & 2 deletions src/data-structures/doubly-linked-list/README.md
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ Remove(head, value)
return true
end if
n ← head.next
while n = ø and value = n.value
while n = ø and value !== n.value
n ← n.next
end while
if n = tail
@@ -100,7 +100,7 @@ end Reverse Traversal

| Access | Search | Insertion | Deletion |
| :-------: | :-------: | :-------: | :-------: |
| O(n) | O(n) | O(1) | O(1) |
| O(n) | O(n) | O(1) | O(n) |

### Space Complexity

4 changes: 2 additions & 2 deletions src/data-structures/hash-table/HashTable.js
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ export default class HashTable {
bucketLinkedList.append({ key, value });
} else {
// Update value of existing node.
node.value.value = value;
node.value = value;
}
}

@@ -88,7 +88,7 @@ export default class HashTable {
const bucketLinkedList = this.buckets[this.hash(key)];
const node = bucketLinkedList.find({ callback: nodeValue => nodeValue.key === key });

return node ? node.value.value : undefined;
return node ? node.value : undefined;
}

/**