/TypeScript-Data-Structures-and-Algorithms

TypeScript数据结构与算法,Fork自《学习Javascript数据结构与算法,第三版》源码

Primary LanguageTypeScriptMIT LicenseMIT

Learning JavaScript Data Structures and Algorithms

Build Status codecov devDependencies Status dependencies Status Greenkeeper badge

Source code of Learning JavaScript Data Structures and Algorithms book, third edition.

Learning JavaScript Data Structures and Algorithms - Third Edition

This is the code repository for Learning JavaScript Data Structures and Algorithms - Third Edition, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

About the Book

JavaScript is one of the most popular programming language nowadays. It is known as the internet language due the fact that the browser understands JavaScript natively, without installing any plugins in it. JavaScript has grown so much that is no longer just a frontend language; it is also present now on the server (NodeJS), database (MongoDB), and mobile devices and is also used in embedded and Internet of Things (IoT) devices.

Learning data structures is very important for any technology professional. Working as a developer means you are able to solve problems with the help of programming languages, and data structures are an indispensable piece of the solutions we need to create to solve these problems. Choosing a wrong data structure can also have an impact on the performance of the program we are writing. That is why, it's important to get to know different data structures and how to apply them properly.

Algorithms are the state of art of computer science. There are so many ways of solving the same problem, and some approaches are better than the others. That is why, it's also very important to know the most famous algorithms. This book was written for beginners who want to learn data structures and algorithms and also for those who are already familiar with data structures and algorithms, but want to learn it using JavaScript.

Happy coding!

Instructions and Navigation

All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

The code will look like the following:

class Stack {
  constructor() {
    this.items = []; // {1}
  }
}

Although this book provides a brief introduction on JavaScript in its first chapter, you will need a basic knowledge of JavaScript and programming logic.

To test the code examples provided by this book, you will need a code editor (such as Atom or Visual Studio Code) so that you can read the code and also a browser (Chrome, Firefox, or Edge).

Also, remember to open the developer tools of the browser so that you can see what is being outputted in the browser's console.

Related Products

List of available chapters:

Third Edition Updates

  • Algorithms using ES2015+ (ES6+)
  • New data structures and algorithms
  • All chapters rewritten and reviewed
  • Three (3) new chapters
  • Creation of a Data Structures and Algorithms library that can be used in the browser or with Node.js
  • Algorithms tested with Mocha + Chai (test code available in test directory)
  • TypeScript version of the source code included (library and tests)

Project Structure

src/js/index.js file contains all the data structures and algorithms listed by chapter.

|_examples (how to use each data structure and algorithm, organized by chapter)
|_src 
|___js (source code: JavaScript version)
|_____data-structures
|_______models (classes used by DS: Node, ValuePair, ...)
|_____others (other algorithms such as palindome checker, hanoi tower)
|___ts (source code: TypeScript version)
|_____data-structures
|_______models
|_____others
|_test (unit tests with Mocha and Chai for src)
|___js (tests for JavaScript code)
|___ts (tests for TypeScript code)

Installing and running the book examples With Node

  • Install Node
  • Open terminal/cmd and change directoty to this project folder: cd /Users/.../javascript-datastructures-algorithms (Linux/Max) or cd C:/.../javascript-datastructures-algorithms
  • run npm install to install all depencies
  • To see the examples, run http-server html or npm run serve. Open your browser http:\\localhost:8080 to see the book examples
  • Or cd html/chapter01 and run each javascript file with node: node 02-Variables

Running the examples in the browser

Happy Coding!

Other editions

1st edition 2nd edition 3rd edition
1st edition 2nd edition 2nd edition
Book link Book link Book link

Book link - first edition:

Book link - second edition:

Book link - third edition:

Found an issue or have a question?

Please create an Issue or Pull Request