Algorithms JavaScript Explains Algorithms with Beautiful Pictures Learn It Easy Better and Well (yang hu)(Z-Library)
algorithm
No Description
4
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
Algorithms JavaScript YANG HU Simple is the beginning of wisdom. the essence of practice, to briefly explain the concept, and vividly cultivate programming interest, this book deeply analyzes Data Structures Algorithms Javascript and fun of programming. http://en.verejava.com Copyright © 2020 Yang Hu All rights reserved. ISBN: 9798667448785 CONTENTS 1. Linear Table Definition 2. Maximum Value 3. Bubble Sorting Algorithm
Page
3
4. Minimum Value 5. Select Sorting Algorithm 6. Linear Table Append 7. Linear Table Insert 8. Linear Table Delete 9. Insert Sorting Algorithm 10. Reverse Array 11. Linear Table Search 12. Dichotomy Binary Search 13. Shell Sorting 14. Unidirectional Linked List 14.1 Create and Initialization 14.2 Add Node 14.3 Insert Node 14.4 Delete Node 15. Doubly Linked List 15.1 Create and Initialization 15.2 Add Node 15.3 Insert Node 15.4 Delete Node 16. One-way Circular LinkedList 16.1 Initialization and Traversal 16.2 Insert Node 16.3 Delete Node 17. Two-way Circular LinkedList 17.1 Initialization and Traversal
Page
4
17.2 Insert Node 17.3 Delete Node 18. Queue 19. Stack 20. Recursive Algorithm 21. Two-way Merge Algorithm 22. Quick Sort Algorithm 23. Binary Search Tree 23.1 Construct a binary search tree 23.2 Binary search tree In-order traversal 23.3 Binary search tree Pre-order traversal 23.4 Binary search tree Post-order traversal 23.5 Binary search tree Maximum and minimum 23.6 Binary search tree Delete Node 24. Binary Heap Sorting 25. Hash Table 26. Graph 26.1 Directed Graph and Depth-First Search 26.2 Directed Graph and Breadth-First Search 26.3 Directed Graph Topological Sorting 27. Towers of Hanoi 28. Fibonacci 29. Dijkstra 30. Mouse Walking Maze 31. Eight Coins 32. Josephus Problem
Page
5
Linear Table Definition Linear Table: Sequence of elements, is a one-dimensional array. 1. Define a one-dimensional array of student scores 1. Create a TestOneArray.html with Notepad and open it in your browser. <script type="text/javascript"> var scores = new Array( 90, 70, 50, 80, 60, 85 ); //print out the score of the array scores for (var i = 0; i < scores.length; i++) { document.write(scores[i] + ","); } </script> Result:
Page
6
Maximum Value Maximum of Integer Sequences: 1. Algorithmic ideas Compare arrays[i] with arrays[i + 1], if arrays[i] > arrays[i + 1] are exchanged. So continue until the last number, arrays[length - 1] is the maximum.
Page
7
1. Create a TestMaxValue.html with Notepad and open it in your browser. <script type="text/javascript"> function max(arrays) { // Maximum initialization value is 0 for (var i = 0; i < arrays.length - 1; i++) { if (arrays[i] > arrays[i + 1]) { // swap var temp = arrays[i]; arrays[i] = arrays[i + 1]; arrays[i + 1] = temp; } } var maxValue = arrays[arrays.length - 1]; return maxValue; } //////////////////////testing//////////////////// var scores = [ 60, 50, 95, 80, 70]; var maxValue = max(scores); document.write("maxValue = " + maxValue); </script> Result:
Page
8
Bubble Sorting Algorithm Bubble Sorting Algorithm: Compare arrays[j] with arrays[j + 1], if arrays[j] > arrays[j + 1] are exchanged. Remaining elements repeat this process, until sorting is completed. Sort the following numbers from small to large Explanation: No sorting, Comparing, Already sorted
Page
9
1. First sorting:
Page
10
2. Second sorting:
Page
11
3. Third sorting: No swap so terminate sorting : we can get the sorting numbers from small to large
Page
12
1. Create a TestBubbleSort.html with Notepad and open it in your browser. <script type="text/javascript"> class BubbleSort{ static sort(arrays) { for (var i = 0; i < arrays.length - 1; i++) { for (var j = 0; j < arrays.length - i - 1; j++) { //swap if (arrays[j] > arrays[j + 1]) { var flag = arrays[j]; arrays[j] = arrays[j + 1]; arrays[j + 1] = flag; } } } } } //////////////////////testing//////////////////// var scores = [ 60, 50, 95, 80, 70 ]; BubbleSort.sort(scores); for (var i = 0; i < scores.length; i++) { document.write(scores[i] + ","); } </script> Result:
Page
13
(This page has no text content)
Page
14
Minimum Value Search the Minimum of Integer Sequences: 1. Algorithmic ideas Initial value minIndex=0, j=1 Compare arrays[minIndex] with arrays[j] if arrays[minIndex] > arrays[j] then minIndex=j, j++ else j++. continue until the last number, arrays[minIndex] is the Min Value.
Page
15
(This page has no text content)
Page
16
1. Create a TestMinValue.html with Notepad and open it in your browser. <script type="text/javascript"> function min(arrays) { var minIndex = 0;// the index of the minimum for (var j = 1; j < arrays.length; j++) { if (arrays[minIndex] > arrays[j]) { minIndex = j; } } return arrays[minIndex]; } //////////////////////testing//////////////////// var scores = [ 60, 80, 95, 50, 70 ]; var minValue = min(scores); document.write("Min Value = " + minValue); </script> Result:
Page
17
Select Sorting Algorithm Select Sorting Algorithm: Sorts an array by repeatedly finding the minimum element from unsorted part and putting it at the beginning. Sort the following numbers from small to large Explanation: No sorting, Comparing, Already sorted.
Page
18
1. First sorting:
Page
19
2. Second sorting:
Page
20
3. Third sorting:
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A hands-on, visual introduction to classic data structures and algorithms implemented in plain JavaScript, ideal for beginners who learn best by reading code and seeing diagrams rather than dense math.
【Book Arc】
- **Opening (~0%–13%)**: Starts with the simplest linear structure—one-dimensional arrays—and walks through core operations: printing, finding minimum values, inserting elements, and reversing order. Then introduces binary search on sorted arrays, establishing the pattern of "algorithmic idea → code → result" used throughout.
- **Early (~13%–25%)**: Moves from arrays to linked lists, covering singly linked lists with insertion and deletion, then one-way circular lists. The focus is on pointer manipulation and the mechanics of traversing node-based structures.
- **Early–Middle (~25%–38%)**: Extends linked structures into doubly linked circular lists and introduces the queue as a FIFO (first-in, first-out) data structure. Also covers the stack (LIFO) and recursion, using factorial as the canonical example.
- **Middle (~38%–63%)**: Shifts to sorting and trees. Merge sort is presented as a divide-and-conquer algorithm, followed by binary search trees (BST) with insertion, in-order/pre-order/post-order traversal, and searching for min/max values.
- **Late (~63%–88%)**: Covers BST deletion (handling leaf, one-child, and two-child cases), then moves to heap sort and hash tables. Introduces directed graphs represented by adjacency matrices, with depth-first search (DFS) and breadth-first search (BFS) traversal.
- **Ending (~88%–100%)**: Finishes with classic recursion problems—Tower of Hanoi and Fibonacci—plus a maze-solving algorithm using backtracking. The book closes with a request for reader reviews.
【Key Takeaways】
- **Arrays are the entry point to algorithm thinking** (Opening): The book starts with one-dimensional arrays and basic operations like finding the minimum and inserting elements, establishing a pattern of "idea → code → result" that repeats for every data structure. This makes the material approachable for absolute beginners.
- **Binary search is a fundamental divide-and-conquer pattern** (Early): By repeatedly halving the search range on a sorted array, the algorithm reduces complexity from O(n) to O(log n). The book's step-by-step low/high/mid index walkthrough makes this concept concrete.
- **Linked lists teach pointer mechanics** (Early): Unlike arrays, linked lists use nodes with `next` pointers, requiring explicit traversal and careful handling during insertion and deletion. Understanding this prepares you for more complex structures like trees and graphs.
- **Queues and stacks are about access order** (Early–Middle): Queues are FIFO (offer/poll), stacks are LIFO (push/pop). These are the building blocks for many algorithms, and the book shows how to implement them with linked nodes.
- **Recursion is a self-referential loop** (Middle): The factorial example (`factorial(n) = n * factorial(n-1)`) demonstrates how a function calls itself with a smaller input until a base case is reached. This is the foundation for tree traversals and divide-and-conquer algorithms.
- **Binary search trees organize data for fast lookup** (Middle): Insertion, traversal (in-order gives sorted output), and min/max search all rely on the left-smaller/right-larger property. The book's repeated use of the same test data (60, 40, 20, 10, 30, 50, 80, 70, 90) makes comparisons easy.
- **Graphs model relationships with adjacency matrices** (Late): A directed graph stores edges in a 2D array where 1 means "has edge" and 0 means "no edge." DFS and BFS are the two fundamental ways to explore these structures, differing in whether you go deep first or wide first.
- **Classic recursion problems tie everything together** (Ending): Tower of Hanoi, Fibonacci, and maze solving all use recursion plus backtracking. These are the "aha" moments that show how a small set of patterns can solve seemingly complex problems.
【Reading Tips】
- **Skim the "Algorithmic ideas" sections first**: Each topic starts with a plain-language description of the approach (e.g., "compare and swap" for sorting). Read this before diving into code—it's the conceptual anchor.
- **Deep-read the code examples**: The book is built around complete HTML files you can create in Notepad and open in a browser. Type them out (don't copy-paste) to build muscle memory for JavaScript syntax and logic.
- **Watch for repeated test data**: The same array `[50, 65, 99, 87, 74, 63, 76, 100, 92]` and BST values `[60, 40, 20, 10, 30, 50, 80, 70, 90]` appear across chapters. This consistency lets you focus on the algorithm, not the input.
- **Expect some rough edges**: The book is translated and has OCR artifacts (e.g., "s Queue" instead of "class Queue"). Don't get stuck on typos—the logic is clear from context.
- **Skip the math, focus on the mechanics**: There's no Big-O notation or formal proofs. If you want to understand *why* an algorithm works, trace through the code with pencil and paper; if you just want it to work, run the examples.
【Coverage Limits】
This guide covers the data structures and algorithms explicitly shown in the excerpts (arrays, linked lists, queues, stacks, recursion, merge sort, BST, heap sort, hash tables, graphs, DFS/BFS, Tower of Hanoi, Fibonacci, maze solving). It does not cover any content missing from the sampled chunks, such as detailed complexity analysis or advanced topics like dynamic programming or graph shortest paths.
Passage locations
Excerpt 1
书名: Algorithms JavaScript Explains Algorithms with Beautiful Pictures Learn It Easy Better and Well (yang hu) (z-library.sk, 1lib.sk, z-lib.sk) 作者: yang hu L...
View in text
Excerpt 2
ition - 1) { p = p.next; i++; } 4. Delete the index=2 node. One-way Circular LinkedList One-way Circular List: It is a chain storage structure of a linear ta...
View in text
Excerpt 3
s Queue{ constructor(){ this.head = null; this.tail = null; this.size = 0; } offer(element) { if (this.head == null) { this.head = new Node(element); this.ta...
View in text
Excerpt 4
ert(binaryTree.getRoot(), 80); binaryTree.insert(binaryTree.getRoot(), 70); binaryTree.insert(binaryTree.getRoot(), 90); document.write("<br> Post-order trav...
View in text
Support Author
0.00
Total Amount (¥)
0
Donation Count
Please enter an amount
Minimum ¥1
You will be redirected to Alipay to complete payment, then return here.
Order created — please complete Alipay payment
{{#payUrl}} Pay with Alipay {{/payUrl}} {{^payUrl}}{{message}}
{{/payUrl}}
Donation failed:{{message}}
Log in to link the donation to your account (anonymous payment also works)
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later