Skip to content

Commit 71d1610

Browse files
authored
Merge pull request #228 from loiane/main
sync with main
2 parents 73139fe + e00c298 commit 71d1610

25 files changed

+9115
-12881
lines changed

Diff for: .gitattributes

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Handle line endings automatically for files detected as text
2+
# and leave all files detected as binary untouched.
3+
* text=auto
4+
5+
#
6+
# The above will handle all files NOT found below
7+
#
8+
# These files are text and should be normalized (Convert crlf => lf)
9+
*.css eol=lf
10+
*.df eol=lf
11+
*.htm eol=lf
12+
*.html eol=lf
13+
*.java eol=lf
14+
*.js eol=lf
15+
*.json eol=lf
16+
*.jsp eol=lf
17+
*.jspf eol=lf
18+
*.jspx eol=lf
19+
*.properties eol=lf
20+
*.sh eol=lf
21+
*.tld eol=lf
22+
*.txt eol=lf
23+
*.tag eol=lf
24+
*.tagx eol=lf
25+
*.xml eol=lf
26+
*.yml eol=lf
27+
28+
# These files are binary and should be left untouched
29+
# (binary is a macro for -text -diff)
30+
*.class binary
31+
*.dll binary
32+
*.ear binary
33+
*.gif binary
34+
*.ico binary
35+
*.jar binary
36+
*.jpg binary
37+
*.jpeg binary
38+
*.png binary
39+
*.so binary
40+
*.war binary

Diff for: .vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "chrome",
99
"request": "launch",
1010
"name": "Chrome",
11-
"url": "http://127.0.0.1:8887/examples",
11+
"url": "http://127.0.0.1:8080/examples",
1212
"webRoot": "${workspaceRoot}"
1313
},
1414
{

Diff for: examples/chapter01_02/04-TruthyFalsy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ testTruthy({}); // true (object is always true)
2424
var obj = { name: 'John' };
2525
testTruthy(obj); // true
2626
testTruthy(obj.name); // true
27-
testTruthy(obj.age); // age (property does not exist)
27+
testTruthy(obj.age); // false (property age does not exist)

Diff for: examples/chapter09/04-Fibonacci.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function fibonacciMemoization(n) {
3030
const memo = [0, 1];
3131
const fibonacci = (n) => {
3232
if (memo[n] != null) return memo[n];
33-
return memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo);
33+
return memo[n] = fibonacci(n - 1) + fibonacci(n - 2);
3434
};
3535
return fibonacci(n);
3636
}

Diff for: examples/chapter10/01-UsingMinHeap.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
<script src="./../PacktDataStructuresAlgorithms.min.js"></script>
9+
<script src="01-UsingMinHeap.js"></script>
10+
</body>
11+
</html>

Diff for: examples/chapter10/01-UsingMinHeap.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { MinHeap } = PacktDataStructuresAlgorithms;
2+
3+
let heap = new MinHeap();
4+
5+
heap.insert(2);
6+
heap.insert(3);
7+
heap.insert(4);
8+
heap.insert(5);
9+
10+
heap.insert(2);
11+
12+
console.log(heap.getAsArray());
13+
14+
console.log('Heap size: ', heap.size()); // 5
15+
console.log('Heap is empty: ', heap.isEmpty()); // false
16+
console.log('Heap min value: ', heap.findMinimum()); // 1
17+
18+
heap = new MinHeap();
19+
for (let i = 1; i < 10; i++) {
20+
heap.insert(i);
21+
}
22+
23+
console.log(heap.getAsArray());
24+
25+
console.log('Extract minimum: ', heap.extract()); // 1
26+
console.log(heap.getAsArray()); // [2, 4, 3, 8, 5, 6, 7, 9]
27+

Diff for: examples/chapter10/02-UsingMaxHeap.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
<script src="./../PacktDataStructuresAlgorithms.min.js"></script>
9+
<script src="02-UsingMaxHeap.js"></script>
10+
</body>
11+
</html>

Diff for: examples/chapter10/02-UsingMaxHeap.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { MaxHeap } = PacktDataStructuresAlgorithms;
2+
3+
const maxHeap = new MaxHeap();
4+
5+
maxHeap.insert(2);
6+
maxHeap.insert(3);
7+
maxHeap.insert(4);
8+
maxHeap.insert(5);
9+
10+
maxHeap.insert(1);
11+
12+
console.log(maxHeap.getAsArray());
13+
14+
console.log('Heap size: ', maxHeap.size()); // 5
15+
console.log('Heap is empty: ', maxHeap.isEmpty()); // false
16+
console.log('Heap min value: ', maxHeap.findMinimum()); // 5
17+
18+
maxHeap.insert(6);
19+
maxHeap.insert(9);
20+
maxHeap.insert(10);
21+
maxHeap.insert(14);
22+
23+
console.log(maxHeap.getAsArray());
24+
25+
console.log('Extract minimum: ', maxHeap.extract());
26+
console.log(maxHeap.getAsArray());
27+

Diff for: examples/chapter10/03-HeapSort.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
<script src="./../PacktDataStructuresAlgorithms.min.js"></script>
9+
<script src="03-HeapSort.js"></script>
10+
</body>
11+
</html>

Diff for: examples/chapter10/03-HeapSort.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { heapSort } = PacktDataStructuresAlgorithms;
2+
3+
console.log('********** Heap Sort **********');
4+
const array = [7, 6, 3, 5, 4, 1, 2];
5+
6+
console.log('Before sorting: ', array);
7+
console.log('After sorting: ', heapSort(array));

Diff for: examples/index.html

+10-7
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,18 @@
194194
</div>
195195
</section>
196196
<section class="mdl-layout__tab-panel" id="scroll-tab-10">
197-
<div class="page-content">
198-
<div class="page-content mdl-layout--fixed-drawer">
199-
<div class="mdl-layout__drawer is-visible">
200-
<nav class="mdl-navigation">
201-
</nav>
202-
</div>
197+
<div class="page-content">
198+
<div class="page-content mdl-layout--fixed-drawer">
199+
<div class="mdl-layout__drawer is-visible">
200+
<nav class="mdl-navigation">
201+
<a class="mdl-navigation__link" href="chapter10/01-UsingMinHeap.html">01-UsingMinHeap</a>
202+
<a class="mdl-navigation__link" href="chapter10/02-UsingMaxHeap.html">02-UsingMaxHeap</a>
203+
<a class="mdl-navigation__link" href="chapter10/03-HeapSort.html">03-HeapSort</a>
204+
</nav>
203205
</div>
204206
</div>
205-
</section>
207+
</div>
208+
</section>
206209
<section class="mdl-layout__tab-panel" id="scroll-tab-11">
207210
<div class="page-content">
208211
<div class="page-content mdl-layout--fixed-drawer">

0 commit comments

Comments
 (0)