Skip to content

Master #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Dec 23, 2020
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
168f71b
updated README
loiane May 1, 2018
5bd0395
Merge branch 'master' of https://github.com/loiane/javascript-datastr…
loiane Mar 15, 2019
0f4dbab
Merge pull request #120 from loiane/third-edition
loiane Mar 15, 2019
13702e4
npm audit fix
loiane Mar 15, 2019
b7170d1
Merge pull request #121 from loiane/third-edition
loiane Mar 15, 2019
e734651
eslint update + fixed new js lint issues
loiane Mar 15, 2019
817db9e
Merge pull request #122 from loiane/third-edition
loiane Mar 15, 2019
cf55965
updated readme: chinese + portuguese links 3rd ed
loiane Mar 15, 2019
703767a
tslint update + fixed new ts lint issues
loiane Mar 15, 2019
021ebd7
Merge pull request #123 from loiane/third-edition
loiane Mar 15, 2019
c843462
chore(package): update webpack-cli to version 3.3.0
greenkeeper[bot] Mar 16, 2019
706f36d
chore(package): update lockfile package-lock.json
greenkeeper[bot] Mar 16, 2019
c1c374f
Merge pull request #124 from loiane/greenkeeper/webpack-cli-3.3.0
loiane Mar 16, 2019
f64d9d8
Update README.md
ayomel Apr 1, 2019
0e0ba57
grammar correction
shockyng May 8, 2019
01e35d4
Bump mixin-deep from 1.3.1 to 1.3.2
dependabot[bot] Oct 29, 2019
3236269
Bump acorn from 6.1.1 to 6.4.1
dependabot[bot] Mar 13, 2020
0a606fd
Bump https-proxy-agent from 2.2.1 to 2.2.4
dependabot[bot] Apr 16, 2020
ae6c563
Bump lodash from 4.17.10 to 4.17.19
dependabot[bot] Jul 16, 2020
2acc2db
Merge pull request #134 from LuanHenriqueR8/master
loiane Jul 19, 2020
1bce038
Merge pull request #156 from loiane/dependabot/npm_and_yarn/lodash-4.…
loiane Jul 19, 2020
10df6bc
Merge pull request #155 from loiane/dependabot/npm_and_yarn/https-pro…
loiane Jul 19, 2020
a23fcdb
Bump eslint-utils from 1.3.1 to 1.4.3
dependabot[bot] Jul 19, 2020
25be7be
Bump codecov from 3.2.0 to 3.6.5
dependabot[bot] Jul 19, 2020
d326a23
Bump handlebars from 4.0.10 to 4.7.6
dependabot[bot] Jul 19, 2020
b7656b8
Merge branch 'master' into patch-1
loiane Jul 19, 2020
0e2c40f
Merge pull request #126 from mhunter11/patch-1
loiane Jul 19, 2020
6021ccd
Merge pull request #149 from loiane/dependabot/npm_and_yarn/mixin-dee…
loiane Jul 19, 2020
98a6f52
Merge pull request #153 from loiane/dependabot/npm_and_yarn/acorn-6.4.1
loiane Jul 19, 2020
169f5de
Merge pull request #158 from loiane/dependabot/npm_and_yarn/handlebar…
loiane Jul 19, 2020
a3e72d8
Merge pull request #157 from loiane/dependabot/npm_and_yarn/eslint-ut…
loiane Jul 19, 2020
6bda9e6
Merge pull request #152 from loiane/dependabot/npm_and_yarn/codecov-3…
loiane Jul 19, 2020
a0d4200
Bump fstream from 1.0.11 to 1.0.12
dependabot[bot] Jul 19, 2020
22eb236
Bump js-yaml from 3.10.0 to 3.13.1
dependabot[bot] Jul 19, 2020
39ac473
Bump codecov from 3.6.5 to 3.7.1
dependabot[bot] Jul 21, 2020
ebe7e38
Bump elliptic from 6.4.1 to 6.5.3
dependabot[bot] Jul 30, 2020
4bedf17
Merge pull request #160 from loiane/dependabot/npm_and_yarn/fstream-1…
loiane Jul 30, 2020
d077ff4
Merge pull request #161 from loiane/dependabot/npm_and_yarn/js-yaml-3…
loiane Jul 30, 2020
a7cd4a3
Merge pull request #162 from loiane/dependabot/npm_and_yarn/codecov-3…
loiane Jul 30, 2020
8151ba0
Merge pull request #163 from loiane/dependabot/npm_and_yarn/elliptic-…
loiane Jul 30, 2020
ec96129
restored chapter 10 examples
Nov 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,8 @@
"prefer-destructuring": ["error", {"object": true, "array": false}],
"padded-blocks": 0,
"no-sparse-arrays": 0,
"array-bracket-spacing": 0
"array-bracket-spacing": 0,
"import/no-named-as-default": 0,
"implicit-arrow-linebreak": 0
}
}
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Learning JavaScript Data Structures and Algorithms
====================================

[![Build Status](https://travis-ci.org/loiane/javascript-datastructures-algorithms.svg?branch=third-edition)](https://travis-ci.org/loiane/javascript-datastructures-algorithms)
[![Build Status](https://travis-ci.org/loiane/javascript-datastructures-algorithms.svg?branch=master)](https://travis-ci.org/loiane/javascript-datastructures-algorithms)
[![codecov](https://codecov.io/gh/loiane/javascript-datastructures-algorithms/branch/master/graph/badge.svg)](https://codecov.io/gh/loiane/javascript-datastructures-algorithms)
[![devDependencies Status](https://david-dm.org/loiane/javascript-datastructures-algorithms/dev-status.svg)](https://david-dm.org/loiane/javascript-datastructures-algorithms?type=dev)
[![dependencies Status](https://david-dm.org/loiane/javascript-datastructures-algorithms/status.svg)](https://david-dm.org/loiane/javascript-datastructures-algorithms)
@@ -61,16 +61,16 @@ Source code of **Learning JavaScript Data Structures and Algorithms** book, thir
## Installing and running the book examples With Node

* Install [Node](https://nodejs.org)
* 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
* Open terminal/cmd and change directory to this project folder: `cd /Users/.../javascript-datastructures-algorithms` (Linux/Max) or `cd C:/.../javascript-datastructures-algorithms`
* run `npm install` to install all dependencies
* 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

* Right click on the html file you would like to see the examples, right click and 'Open with Chrome (or any other browser)'

* Or open the `examples/index.html` file to easily nagivate through all examples:
* Or open the `examples/index.html` file to easily navigate through all examples:

* Demo: [https://javascript-ds-algorithms-book.firebaseapp.com](https://javascript-ds-algorithms-book.firebaseapp.com)

@@ -100,6 +100,8 @@ Book link - second edition:
Book link - third edition:
- [Packt](https://www.packtpub.com/web-development/learning-javascript-data-structures-and-algorithms-third-edition)
- [Amazon](http://a.co/cbMlYmJ)
- [Chinese version](http://www.ituring.com.cn/book/2653)
- [Brazilian Portuguese version](https://novatec.com.br/livros/estruturas-de-dados-algoritmos-em-javascript-2ed/)

### Found an issue or have a question?

11 changes: 11 additions & 0 deletions examples/chapter10/01-UsingMinHeap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="./../PacktDataStructuresAlgorithms.min.js"></script>
<script src="01-UsingMinHeap.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions examples/chapter10/01-UsingMinHeap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { MinHeap } = PacktDataStructuresAlgorithms;

let heap = new MinHeap();

heap.insert(2);
heap.insert(3);
heap.insert(4);
heap.insert(5);

heap.insert(2);

console.log(heap.getAsArray());

console.log('Heap size: ', heap.size()); // 5
console.log('Heap is empty: ', heap.isEmpty()); // false
console.log('Heap min value: ', heap.findMinimum()); // 1

heap = new MinHeap();
for (let i = 1; i < 10; i++) {
heap.insert(i);
}

console.log(heap.getAsArray());

console.log('Extract minimum: ', heap.extract()); // 1
console.log(heap.getAsArray()); // [2, 4, 3, 8, 5, 6, 7, 9]

11 changes: 11 additions & 0 deletions examples/chapter10/02-UsingMaxHeap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="./../PacktDataStructuresAlgorithms.min.js"></script>
<script src="02-UsingMaxHeap.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions examples/chapter10/02-UsingMaxHeap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { MaxHeap } = PacktDataStructuresAlgorithms;

const maxHeap = new MaxHeap();

maxHeap.insert(2);
maxHeap.insert(3);
maxHeap.insert(4);
maxHeap.insert(5);

maxHeap.insert(1);

console.log(maxHeap.getAsArray());

console.log('Heap size: ', maxHeap.size()); // 5
console.log('Heap is empty: ', maxHeap.isEmpty()); // false
console.log('Heap min value: ', maxHeap.findMinimum()); // 5

maxHeap.insert(6);
maxHeap.insert(9);
maxHeap.insert(10);
maxHeap.insert(14);

console.log(maxHeap.getAsArray());

console.log('Extract minimum: ', maxHeap.extract());
console.log(maxHeap.getAsArray());

11 changes: 11 additions & 0 deletions examples/chapter10/03-HeapSort.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="./../PacktDataStructuresAlgorithms.min.js"></script>
<script src="03-HeapSort.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/chapter10/03-HeapSort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { heapSort } = PacktDataStructuresAlgorithms;

console.log('********** Heap Sort **********');
const array = [7, 6, 3, 5, 4, 1, 2];

console.log('Before sorting: ', array);
console.log('After sorting: ', heapSort(array));
17 changes: 10 additions & 7 deletions examples/index.html
Original file line number Diff line number Diff line change
@@ -194,15 +194,18 @@
</div>
</section>
<section class="mdl-layout__tab-panel" id="scroll-tab-10">
<div class="page-content">
<div class="page-content mdl-layout--fixed-drawer">
<div class="mdl-layout__drawer is-visible">
<nav class="mdl-navigation">
</nav>
</div>
<div class="page-content">
<div class="page-content mdl-layout--fixed-drawer">
<div class="mdl-layout__drawer is-visible">
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="chapter10/01-UsingMinHeap.html">01-UsingMinHeap</a>
<a class="mdl-navigation__link" href="chapter10/02-UsingMaxHeap.html">02-UsingMaxHeap</a>
<a class="mdl-navigation__link" href="chapter10/03-HeapSort.html">03-HeapSort</a>
</nav>
</div>
</div>
</section>
</div>
</section>
<section class="mdl-layout__tab-panel" id="scroll-tab-11">
<div class="page-content">
<div class="page-content mdl-layout--fixed-drawer">
Loading