Share E-Book

Algorithms JavaScript Explains Algorithms with Beautiful Pictures Learn It Easy Better and Well (yang hu)(Z-Library)

Author yang hu

algorithm
Language English

No Description

Format PDF
Size 7.9 MB
4
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

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.

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.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List