# humanwhocodes/computer-science-in-javascript

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/humanwhocodes-computer-science-in-javascript).**

9,119 stars · 1,179 forks · JavaScript · MIT

## Links

- GitHub: https://github.com/humanwhocodes/computer-science-in-javascript
- Homepage: http://www.nczonline.net/
- awesome-repositories: https://awesome-repositories.com/repository/humanwhocodes-computer-science-in-javascript.md

## Description

This is a collection of classic computer science algorithms and data structures implemented from scratch in JavaScript. The project provides reference implementations of fundamental concepts including sorting algorithms, binary search, linked lists, and binary search trees, all built as standalone pure functions with no external dependencies.

The implementations cover a range of data structures, including singly-linked, doubly-linked, and circular linked lists with full traversal and mutation operations, as well as binary search trees supporting insertion, deletion, and search. Sorting algorithms such as bubble sort and selection sort are included, alongside binary search for efficient lookup in sorted arrays. The project also provides base64 encoding and decoding utilities for binary-to-text data conversion, and a Luhn algorithm implementation for validating numeric identifiers like credit card numbers.

Each module is designed as an independent, reusable function, making the collection suitable for studying how these algorithms and data structures work internally. The code uses JavaScript generator functions to provide iterable interfaces for custom data structures, enabling use with standard iteration protocols.

## Tags

### Education & Learning Resources

- [Algorithm Implementations](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/algorithms/general-collections-and-study/algorithm-implementations.md) — Provides standalone JavaScript implementations of classic computer science algorithms.
- [Computer Science Education](https://awesome-repositories.com/f/education-learning-resources/technical-domain-education/computer-science-education.md) — Provides educational implementations of classic computer science algorithms and data structures in JavaScript.
- [Algorithm Demonstrations](https://awesome-repositories.com/f/education-learning-resources/algorithm-demonstrations.md) — Demonstrates common algorithmic patterns such as recursion and tree traversal with working code examples. ([source](https://humanwhocodes.com/blog/categories/computer-science-in-javascript/))
- [Binary Search Implementations](https://awesome-repositories.com/f/education-learning-resources/binary-search-implementations.md) — Implements binary search for efficiently locating values in sorted arrays.
- [JavaScript Implementations](https://awesome-repositories.com/f/education-learning-resources/binary-search-implementations/javascript-implementations.md) — Implements binary search on sorted arrays for efficient O(log n) element lookup in JavaScript.
- [Doubly Linked Lists](https://awesome-repositories.com/f/education-learning-resources/data-structure-implementations/doubly-linked-lists.md) — Implements doubly-linked lists with bidirectional traversal using next and previous pointers. ([source](https://humanwhocodes.com/blog/2009/04/21/computer-science-in-javascript-doubly-linked-lists/))
- [Algorithm Implementation Practice](https://awesome-repositories.com/f/education-learning-resources/problem-solving-guides/interview-problem-solving/algorithm-implementation-practice.md) — Provides practical code implementations of classic sorting, searching, and tree algorithms for study.
- [Sorting Algorithms](https://awesome-repositories.com/f/education-learning-resources/sorting-algorithms.md) — Implements classic sorting algorithms such as bubble sort and selection sort. ([source](https://humanwhocodes.com/blog/categories/computer-science-in-javascript/))
- [JavaScript Implementations](https://awesome-repositories.com/f/education-learning-resources/technical-domain-education/computer-science-education/computer-science-concepts/javascript-implementations.md) — Provides a collection of classic computer science algorithms and data structures implemented in JavaScript for learning and reference.

### Data & Databases

- [Data Structure Implementations](https://awesome-repositories.com/f/data-databases/data-structure-implementations.md) — Implements foundational data structures like linked lists and binary search trees from scratch. ([source](https://humanwhocodes.com/blog/categories/computer-science-in-javascript/))
- [Collection Iterators](https://awesome-repositories.com/f/data-databases/collection-iterators.md) — Implement a generator that yields each item in sequence for use with for-of loops and destructuring. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))
- [Generator-Based Iterators](https://awesome-repositories.com/f/data-databases/collection-iterators/sequential-iterators/generator-based-iterators.md) — Uses JavaScript generator functions to provide iterable interfaces for linked lists and trees. ([source](https://humanwhocodes.com/blog/2019/03/computer-science-in-javascript-circular-doubly-linked-lists/))
- [Index-Based Retrievals](https://awesome-repositories.com/f/data-databases/graph-node-property-management/node-retrieval/index-based-retrievals.md) — Walk the list from the head to find and return the node at a given index. ([source](https://humanwhocodes.com/blog/2019/02/computer-science-in-javascript-doubly-linked-lists/))

### Programming Languages & Runtimes

- [JavaScript Implementations](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/language-specific-resources/systems-and-performance-languages/go-resources/data-structure-libraries/javascript-implementations.md) — Implements fundamental data structures like linked lists, binary search trees, and circular lists in JavaScript.
- [Binary Search Trees](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-structures/hierarchical-tree-structures/binary-search-trees.md) — Implements binary search trees with insertion, deletion, and search operations maintaining the binary search property. ([source](https://cdn.jsdelivr.net/gh/humanwhocodes/computer-science-in-javascript@master/README.md))
- [Linked Lists](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-structures/linear-collections/linked-lists.md) — Organize values in a linear sequence where each element points to the next, enabling efficient insertion and removal without reindexing. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))
- [Circular Index Removals](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-structures/linear-collections/linked-lists/linked-list-indexing/circular-index-removals.md) — Implements index-based node removal for circular doubly linked lists. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))
- [Circular Index Retrievals](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-structures/linear-collections/linked-lists/linked-list-indexing/circular-index-retrievals.md) — Retrieves node data by index from a circular doubly linked list. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))

### Scientific & Mathematical Computing

- [Binary Search Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/binary-search-algorithms.md) — Implements binary search and binary search tree operations that repeatedly halve the search space.
- [Data Structure Implementations](https://awesome-repositories.com/f/scientific-mathematical-computing/data-structure-implementations.md) — Implements fundamental data structures including linked lists, binary search trees, and circular lists from scratch.
- [Sorting Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/sorting-algorithms.md) — Implements classic sorting algorithms such as bubble sort and selection sort as reusable array manipulation functions.

### Software Engineering & Architecture

- [Linked Lists](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists.md) — Store a sequence of elements where each node points to the next, enabling efficient insertions and deletions. ([source](https://cdn.jsdelivr.net/gh/humanwhocodes/computer-science-in-javascript@master/README.md))
- [Linked List Manipulation Utilities](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/linked-list-manipulation-utilities.md) — Provides linked list, doubly-linked list, and circular linked list implementations with full traversal and mutation operations.
- [Node Insertion Techniques](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-insertion-techniques.md) — Implements linked list variants with nodes connected by next and previous pointers for constant-time insertions and deletions.
- [Singly](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/singly.md) — Implements a singly-linked list data structure with full traversal and mutation operations. ([source](https://cdn.jsdelivr.net/gh/humanwhocodes/computer-science-in-javascript@master/README.md))
- [Classic Array Sorting Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/array-rearrangement-algorithms/classic-array-sorting-algorithms.md) — Implements classic sorting algorithms such as bubble sort and selection sort for array ordering. ([source](https://humanwhocodes.com/blog/categories/computer-science-in-javascript/))
- [Bubble Sorts](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/bubble-sorts.md) — Implements bubble sort as a standalone sorting algorithm in JavaScript. ([source](https://humanwhocodes.com/blog/2009/05/26/computer-science-in-javascript-bubble-sort/))
- [Swap-Based Sorting Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/bubble-sorts/swap-based-sorting-algorithms.md) — Implements bubble sort and selection sort, both of which rearrange arrays by repeatedly swapping elements.
- [Standard Binary Searches](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/sorted-array-searchers/standard-binary-searches.md) — Implements binary search on sorted arrays for efficient O(log n) element lookup. ([source](https://cdn.jsdelivr.net/gh/humanwhocodes/computer-science-in-javascript@master/README.md))
- [Base64 Encoding and Decoding](https://awesome-repositories.com/f/software-engineering-architecture/base64-encoding-and-decoding.md) — Provides base64 encoding and decoding utilities for binary-to-text data conversion.
- [List Traversal Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/list-traversal-algorithms.md) — Implements sequential traversal of singly-linked lists by following next pointers. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))
- [Circular List Traversals](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/list-traversal-algorithms/circular-list-traversals.md) — Traverses circular doubly linked lists with a post-test loop for head detection. ([source](https://humanwhocodes.com/blog/2019/03/computer-science-in-javascript-circular-doubly-linked-lists/))
- [Reverse Traversals](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/list-traversal-algorithms/reverse-traversals.md) — Implements reverse iteration for doubly-linked and circular linked lists by following previous pointers. ([source](https://humanwhocodes.com/blog/2019/02/computer-science-in-javascript-doubly-linked-lists/))
- [Circular Tail Insertions](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-insertion-techniques/circular-tail-insertions.md) — Inserts nodes at the tail of a circular doubly linked list with constant-time pointer updates. ([source](https://humanwhocodes.com/blog/2019/03/computer-science-in-javascript-circular-doubly-linked-lists/))
- [Tail Insertions](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-insertion-techniques/sibling-insertions/tail-insertions.md) — Insert a new node at the end of the list in constant time by using the tracked tail pointer. ([source](https://humanwhocodes.com/blog/2019/02/computer-science-in-javascript-doubly-linked-lists/))
- [Tail Insertions](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-insertion-techniques/tail-insertions.md) — Insert a new node at the end of the list by traversing to the last node and linking it. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))
- [Node Removal Techniques](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-removal-techniques.md) — Delete a specified node from a sequence and reconnects its neighbors, handling first and last positions specially. ([source](https://humanwhocodes.com/blog/2009/04/21/computer-science-in-javascript-doubly-linked-lists/))
- [Doubly-Linked List Removals](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-removal-techniques/doubly-linked-list-removals.md) — Delete a node at a given index by adjusting the previous and next pointers of surrounding nodes. ([source](https://humanwhocodes.com/blog/2009/04/21/computer-science-in-javascript-doubly-linked-lists/))
- [Positional Removals](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/node-removal-techniques/positional-removals.md) — Find a node at a given index and remove it while updating both next and previous pointers of adjacent nodes. ([source](https://humanwhocodes.com/blog/2019/02/computer-science-in-javascript-doubly-linked-lists/))
- [Selection Sorts](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/selection-sorts.md) — Provides a standalone implementation of the selection sort algorithm for educational reference. ([source](https://humanwhocodes.com/blog/2009/09/08/computer-science-in-javascript-selection-sort/))
- [Tree Traversal Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/tree-traversal-algorithms.md) — Implements in-order traversal of binary search trees to output values in sorted order. ([source](https://humanwhocodes.com/blog/categories/computer-science-in-javascript/))
- [In-Order Iterators](https://awesome-repositories.com/f/software-engineering-architecture/tree-traversal-algorithms/in-order-iterators.md) — Binary search tree values are output in sorted order by recursively visiting left subtree, current node, then right subtree.

### Part of an Awesome List

- [Structure Iterators](https://awesome-repositories.com/f/awesome-lists/data/json-processing/structure-iterators.md) — Yield each data item in sequence using a generator, making the list usable with loops and spread syntax. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))

### Security & Cryptography

- [Luhn Algorithm Validators](https://awesome-repositories.com/f/security-cryptography/checksum-validated-downloads/luhn-algorithm-validators.md) — Provides a Luhn algorithm implementation for validating credit card numbers.

### User Interface & Experience

- [Circular Infinite Iterations](https://awesome-repositories.com/f/user-interface-experience/data-iterators/prompt-list-iteration/list-iteration/circular-infinite-iterations.md) — Provides infinite iteration over circular doubly linked list data using generators. ([source](https://humanwhocodes.com/blog/2019/03/computer-science-in-javascript-circular-doubly-linked-lists/))
- [Circular Value Iterations](https://awesome-repositories.com/f/user-interface-experience/data-iterators/prompt-list-iteration/list-iteration/circular-value-iterations.md) — Iterates over circular doubly linked list values using JavaScript generator functions. ([source](https://humanwhocodes.com/blog/2019/03/computer-science-in-javascript-circular-doubly-linked-lists/))
- [Generator-Based Iterators](https://awesome-repositories.com/f/user-interface-experience/data-iterators/prompt-list-iteration/list-iteration/generator-based-iterators.md) — Make the list usable with for-of loops and destructuring by implementing a values generator. ([source](https://humanwhocodes.com/blog/2019/01/computer-science-in-javascript-linked-list/))
