Skip to content

Commit dd2dcea

Browse files
committed
New
1 parent 38c56b3 commit dd2dcea

7 files changed

Lines changed: 177 additions & 6 deletions

File tree

‎src/h5/effpy/about.txt‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/h5/sjjg/regraph.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>ReGraph</title>
4+
<title>Regraph</title>
55
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
66

77
<style>

‎src/h5/sjjg/resort.html‎

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<html><head><meta charset="utf-8" /><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor/dist/index.css"/><script src="https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor/dist/js/i18n/zh_CN.js"></script><script src="https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor/dist/method.min.js"></script></head><body style="width: 1075px;"><div class="vditor-reset" id="preview"><h1 id="排序">排序<a id="vditorAnchor-排序" class="vditor-anchor" href="#排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h1>
2+
<blockquote>
3+
<p>声明:</p>
4+
<blockquote>
5+
<p>traversal是遍历数组</p>
6+
</blockquote>
7+
<blockquote>
8+
<p>swap是交换算法</p>
9+
</blockquote>
10+
</blockquote>
11+
<h2 id="冒泡排序">冒泡排序<a id="vditorAnchor-冒泡排序" class="vditor-anchor" href="#冒泡排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
12+
<ul>
13+
<li>冒泡排序每次把一个最大的数据往后移动</li>
14+
</ul>
15+
<pre><code class="language-c">void BubbleSort(int arr[], int n){
16+
int i, j;
17+
for (i = 0;i &lt; n - 1;++i){
18+
for (j = 0; j &lt; n - i - 1;++j){
19+
if (arr[j] &gt; arr[j + 1])
20+
swap(&amp;arr[j], &amp;arr[j + 1]);
21+
}
22+
}
23+
traversal(arr, n);
24+
}
25+
</code></pre>
26+
<h2 id="选择排序">选择排序<a id="vditorAnchor-选择排序" class="vditor-anchor" href="#选择排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
27+
<ul>
28+
<li>每次选取未排序中最小的数据换到的前面</li>
29+
</ul>
30+
<pre><code class="language-c">void SelectSort(int arr[], int n){
31+
int i, j, minIndex;
32+
for (i = 0;i &lt; n - 1;++i){
33+
minIndex = i;
34+
for (j = i + 1;j &lt; n;++j)
35+
if (arr[minIndex] &gt; arr[j])
36+
minIndex = j;
37+
if (i != minIndex)
38+
swap(&amp;arr[minIndex], &amp;arr[i]);
39+
}
40+
traversal(arr, n);
41+
}
42+
</code></pre>
43+
<h2 id="插入排序">插入排序<a id="vditorAnchor-插入排序" class="vditor-anchor" href="#插入排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
44+
<ul>
45+
<li>每次把一个数据往前面排好序的数据中比较,不满足往后移,满足则插入</li>
46+
</ul>
47+
<pre><code class="language-c">void InsertSort(int arr[], int n){
48+
int i, j, value;
49+
for (i = 0;i &lt; n - 1;i++){
50+
j = i;
51+
value = arr[i + 1];
52+
while (j &gt;= 0 &amp;&amp; arr[j] &gt; value){
53+
arr[j + 1] = arr[j];
54+
j--;
55+
}
56+
arr[j + 1] = value;
57+
}
58+
traversal(arr, n);
59+
}
60+
</code></pre>
61+
<h2 id="希尔排序">希尔排序<a id="vditorAnchor-希尔排序" class="vditor-anchor" href="#希尔排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
62+
<ul>
63+
<li>每次对间隔数的数据排序,排完每轮之后缩减间隔再排</li>
64+
<li>希尔排序内部采取的是直接插入排序</li>
65+
</ul>
66+
<pre><code class="language-c">void ShellSort(int arr[], int n){
67+
int i, j, gap, value;
68+
for (gap = n / 2;gap &gt;= 1;gap--){
69+
for (i = gap;i &lt; n;i++){
70+
value = arr[i];
71+
for (j = i - gap;j &gt;= 0 &amp;&amp; arr[j] &gt; value; j-= gap)
72+
arr[j + gap] = arr[j];
73+
arr[j + gap] = value;
74+
}
75+
}
76+
traversal(arr, n);
77+
}
78+
</code></pre>
79+
<h2 id="归并排序">归并排序<a id="vditorAnchor-归并排序" class="vditor-anchor" href="#归并排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
80+
<ul>
81+
<li>基于二路归并算法,每次将排序好的数据段合并</li>
82+
</ul>
83+
<pre><code class="language-c">void Merge(int arr[], int reg[], int start, int end){
84+
if (start &gt;= end) return;
85+
int mid, len, leftStart, rightStart, leftEnd, rightEnd;
86+
len = end - start;
87+
mid = len / 2 + start;
88+
leftStart = start;
89+
rightStart = mid + 1;
90+
leftEnd = mid;
91+
rightEnd = end;
92+
Merge(arr, reg, leftStart, leftEnd);
93+
Merge(arr, reg, rightStart, rightEnd);
94+
int k = start;
95+
while (leftStart &lt;= leftEnd &amp;&amp; rightStart &lt;= rightEnd)
96+
reg[k++] = (arr[leftStart] &lt; arr[rightStart]) ? arr[leftStart++] : arr[rightStart++];
97+
while (leftStart &lt;= leftEnd)
98+
reg[k++] = arr[leftStart++];
99+
while (rightStart &lt;= rightEnd)
100+
reg[k++] = arr[rightStart++];
101+
for (int i = start;i &lt;= end;i++)
102+
arr[i] = reg[i];
103+
}
104+
105+
void MergeSort(int arr[], int n){
106+
int reg[n];
107+
Merge(arr, reg, 0, n - 1);
108+
traversal(arr, n);
109+
}
110+
</code></pre>
111+
<h2 id="快速排序">快速排序<a id="vditorAnchor-快速排序" class="vditor-anchor" href="#快速排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
112+
<ul>
113+
<li>找到一个基准数据,将其排到左侧是小于它的数,右侧是不小于它的数的位置,并返回这个位置,然后递归地左右两侧再排</li>
114+
</ul>
115+
<pre><code class="language-c">int Quick(int arr[], int low, int high){
116+
int pivot = arr[low];
117+
while (low &lt; high){
118+
while (low &lt; high &amp;&amp; arr[high] &gt;= pivot)
119+
--high;
120+
arr[low] = arr[high];
121+
while (low &lt; high &amp;&amp; arr[low] &lt; pivot)
122+
++low;
123+
arr[high] = arr[low];
124+
}
125+
arr[low] = pivot;
126+
return low;
127+
}
128+
129+
void QuickSortCore(int arr[], int low, int high){
130+
if (low &lt; high){
131+
int pivot = Quick(arr, low, high);
132+
QuickSortCore(arr, low, pivot - 1);
133+
QuickSortCore(arr, pivot + 1, high);
134+
}
135+
}
136+
137+
void QuickSort(int arr[], int n){
138+
QuickSortCore(arr, 0, n - 1);
139+
traversal(arr, n);
140+
}
141+
</code></pre>
142+
<h2 id="堆排序">堆排序<a id="vditorAnchor-堆排序" class="vditor-anchor" href="#堆排序"><svg viewBox="0 0 16 16" version="1.1" width="16" height="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a></h2>
143+
<pre><code class="language-c">void HeapAdjust(int arr[], int start, int n){
144+
int lchild = start * 2;
145+
int rchild = start * 2 + 1;
146+
int minIndex = start;
147+
if (lchild &lt; n &amp;&amp; arr[lchild] &lt; arr[minIndex])
148+
minIndex = lchild;
149+
if (rchild &lt; n &amp;&amp; arr[rchild] &lt; arr[minIndex])
150+
minIndex = rchild;
151+
if (minIndex != start){
152+
swap(&amp;arr[minIndex], &amp;arr[start]);
153+
HeapAdjust(arr, minIndex, n);
154+
}
155+
}
156+
157+
void HeapSort(int arr[], int n){
158+
for (int i = n / 2;i &gt;= 0;--i)
159+
HeapAdjust(arr, i, n);
160+
for (int i = n - 1;i &gt;= 0;--i){
161+
printf(&quot;%d\t&quot;, arr[0]);
162+
swap(&amp;arr[0], &amp;arr[i]);
163+
HeapAdjust(arr, 0, i);
164+
}
165+
}
166+
</code></pre>
167+
</div><script> const previewElement = document.getElementById('preview'); Vditor.setContentTheme('idea-light', 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor/dist/css/content-theme'); Vditor.codeRender(previewElement); Vditor.highlightRender({"enable":true,"lineNumber":false,"style":"dracula"}, previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor'); Vditor.mathRender(previewElement, { cdn: 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor',math: {"engine":"KaTeX","inlineDigit":true,"macros":{}}}); Vditor.mermaidRender(previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor', 'light'); Vditor.flowchartRender(previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor'); Vditor.graphvizRender(previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor'); Vditor.chartRender(previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor', 'light'); Vditor.mindmapRender(previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor', 'light'); Vditor.abcRender(previewElement, 'https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor'); Vditor.mediaRender(previewElement); Vditor.speechRender(previewElement); </script> <script src="https://cdn.jsdelivr.net/gh/shuzijun/markdown-editor@2.0.5/src/main/resources/vditor/dist/js/icons/ant.js"></script></body></html>

‎src/h5/sjjg/retree.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>ReTree</title>
4+
<title>Retree</title>
55
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
66

77
<style>

‎src/index/article/others.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
<button class="return-button" id="returnButton">返回</button>
9595
</div>
9696
<div class="blog-list-container" id="blogListContainer"></div>
97-
<script src="../../js/others.js">
98-
</script>
97+
<script src="../../js/others.js"></script>
9998
</body>
10099
</html>

‎src/js/Implementation_of_data _structures_and_algorithms.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// 博客列表数据
22
const blogList = [
3+
{
4+
title: '排序算法最终版',
5+
content: '考试前最后一次学排序算法,不在迷惑',
6+
icon: 'https://img-blog.csdnimg.cn/img_convert/7b6054b134b88dd44660e5ab4f9d734a.png',
7+
link: '../../h5/sjjg/resort.html'
8+
},
39
{
410
title: '重新排序算法',
511
content: '重新学排序算法,包括直接排序、希尔排序、什么是堆、快速排序等等等……',

‎src/js/eff.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ document.getElementById('searchInput').addEventListener('keydown', (event) => {
8686
document.getElementById('returnButton').addEventListener('click', returnToAllBlogs);
8787

8888
// 初始化博客列表
89-
initBlogList();
89+
initBlogList();

0 commit comments

Comments
 (0)