Skip to content

Latest commit

 

History

History
48 lines (29 loc) · 2.66 KB

File metadata and controls

48 lines (29 loc) · 2.66 KB

Practical Algorithms and Data Structures

This repo is a work-in-progress port of Bradfield School of Computer Science's Practical Algorithms and Data Structures to TypeScript. That book is subject to a Creative Commons license (having itself been forked from another CC-licensed book), and the source code may be found here. The content of this repo is licensed in kind.

I have stuck reasonably close (but certainly not 100%) to the spirit of the Python implementations provided. But TypeScript is not Python, and I certainly have not matched expression-for-expression. For example, I had to make some typing decisions that are not necessary in the Python version, and insert type guards to accommodate static types.

Tests accompany the code, usually in the corresponding whatever.test.ts file. The tests assume the Deno runtime, because Deno provides a low-fuss way to get a TypeScript project running with testing batteries included 🦕 The full suite can be run from the project directory with deno test.

The non-test code is not particular to Deno, and it is suitable for transpiling to JavaScript with your favourite TypeScript toolchain. Most likely, you are here to read the code, not run it. None of these implementations should be considered robust, performant, or suitable for production use.

Hopefully these translations make the book just a little bit more accessible to folks who know JS or TS, but not Python. 🙃

Table of contents

The numbers refer to the corresponding sections of the book.

Analysis

  1. An Anagram Detection Example

Stacks

  1. A Stack Implementation
  2. Balanced Parentheses
  3. Converting Number Bases
  4. Infix, Prefix and Postfix Expressions

Queues

  1. A Queue Implementation
  2. Simulating Hot Potato

Deques

  1. A Deque Implementation
  2. Palindrome Checker

Lists

  1. An Unordered List Implementation
  2. An Ordered List Implementation

Recursion

  1. Calculating the Sum of a List of Numbers
  2. Converting an Integer to Any Base
  3. Tower of Hanoi
  4. Dynamic Programming