diff --git a/docs/chapter_sorting/quick_sort.md b/docs/chapter_sorting/quick_sort.md index 5c57aac63..766d4d540 100755 --- a/docs/chapter_sorting/quick_sort.md +++ b/docs/chapter_sorting/quick_sort.md @@ -612,7 +612,7 @@ comments: true ## 11.5.4   基准数优化 -**快速排序在某些输入下的时间效率可能降低**。举一个极端例子,假设输入数组是完全倒序的,由于我们选择最左端元素作为基准数,那么在哨兵划分完成后,基准数被交换至数组最右端,导致左子数组长度为 $n - 1$、右子数组长度为 $0$ 。如此递归下去,每轮哨兵划分后的右子数组长度都为 $0$ ,分治策略失效,快速排序退化为“冒泡排序”。 +**快速排序在某些输入下的时间效率可能降低**。举一个极端例子,假设输入数组是完全倒序的,由于我们选择最左端元素作为基准数,那么在哨兵划分完成后,基准数被交换至数组最右端,导致左子数组长度为 $n - 1$、右子数组长度为 $0$ 。如此递归下去,每轮哨兵划分后都有一个子数组的长度为 $0$ ,分治策略失效,快速排序退化为“冒泡排序”的近似形式。 为了尽量避免这种情况发生,**我们可以优化哨兵划分中的基准数的选取策略**。例如,我们可以随机选取一个元素作为基准数。然而,如果运气不佳,每次都选到不理想的基准数,效率仍然不尽如人意。 diff --git a/docs/index.md b/docs/index.md index 828911c49..1e99458c2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,41 +14,109 @@ hide: + +
+ + + + + +

初识算法

+
+ + +

复杂度

+
+ + +

数组与链表

+
+ + +

栈与队列

+
+ + +

哈希表

+
+ + +

+
+ + +

+
+ + +

+
+ + +

搜索

+
+ + +

排序

+
+ + +

分治

+
+ + +

回溯

+
+ + +

动态规划

+
+ + +

贪心

+
+
+
hello-algo-typing-svg -

+

动画图解、一键运行的数据结构与算法教程

- - + + - + d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" /> - 开始阅读 +

开始阅读

- - + - 代码仓库 - - - - - - - 下载 PDF +

代码仓库

@@ -60,84 +128,6 @@ hide:
- - -
- - - - - -

初识算法

-
- - -

复杂度

-
- - -

数组与链表

-
- - -

栈与队列

-
- - -

哈希表

-
- - -

-
- - -

-
- - -

-
- - -

搜索

-
- - -

排序

-
- - -

分治

-
- - -

回溯

-
- - -

动态规划

-
- - -

贪心

-
-
@@ -177,6 +167,18 @@ hide:

提供网页版和 PDF 版,兼容 PC、平板和手机,随时随地阅读

+
+ +
+

下载 PDF

+ + + +
+
+
diff --git a/overrides/stylesheets/extra.css b/overrides/stylesheets/extra.css index 92af94360..684c06bc9 100644 --- a/overrides/stylesheets/extra.css +++ b/overrides/stylesheets/extra.css @@ -112,6 +112,11 @@ text-transform: none; } +.md-typeset a:hover { + color: var(--md-typeset-a-color); + text-decoration: underline; +} + .md-typeset code { border-radius: 0.2rem; } @@ -150,34 +155,6 @@ body { width: 100%; /* Default to full width */ } -/* rounded button */ -.rounded-button { - display: inline-flex; /* Use flexbox for alignment */ - align-items: center; /* Align items vertically */ - justify-content: center; /* Center items horizontally */ - border-radius: 100px; /* Circular corners */ - padding: 9px 18px; /* Padding around the text */ - margin: 0.15em 0; - border: none; /* Removes default border */ - background-color: var(--md-typeset-btn-color); /* Background color */ - color: var(--md-primary-fg-color) !important; /* Text color */ - font-size: 0.85em; /* Font size */ - text-align: center; /* Center the text */ - text-decoration: none; /* Remove underline from anchor text */ - cursor: pointer; /* Pointer cursor on hover */ -} - -.rounded-button:hover { - background-color: var(--md-typeset-btn-hover-color); -} - -.rounded-button svg { - fill: var(--md-primary-fg-color); /* Fill SVG icon with text color */ - width: 1.2em; - height: auto; - margin-right: 0.5em; /* Add some space between the SVG icon and the text */ -} - /* Admonition for python tutor */ .md-typeset .admonition.pythontutor, .md-typeset details.pythontutor { @@ -237,10 +214,69 @@ body { max-width: 70vw; } -.hero-btn { +/* rounded button */ +.rounded-button { + display: inline-flex; + align-items: center; + justify-content: center; + border-radius: 10em; margin: 0 0.1em; padding: 0.5em 1.3em; - font-size: 0.85em; + border: none; + background-color: var(--md-typeset-btn-color); + color: var(--md-primary-fg-color) !important; + text-align: center; + text-decoration: none; + cursor: pointer; +} + +.rounded-button:hover { + background-color: var(--md-typeset-btn-hover-color); +} + +.rounded-button p { + margin: 0; + margin-bottom: 0.1em; +} + +.rounded-button svg { + fill: var(--md-primary-fg-color); + width: auto; + height: 1.2em; + margin-right: 0.5em; +} + +/* text button */ +.text-button-container { + width: 100%; + display: flex; + flex-direction: row; + justify-content: center; + height: auto; + margin: 0 auto; +} + +.text-button { + display: flex; + flex-direction: row; + align-items: center; + color: var(--md-typeset-btn-color); + text-decoration: none; + margin: 0 1em; +} + +.text-button:hover { + text-decoration: underline; +} + +.text-button svg { + display: inline-block; + fill: var(--md-typeset-btn-color); + width: auto; + height: 0.9em; + background-size: cover; + padding-top: 0.17em; + margin-left: 0.4em; } /* hero image */ @@ -284,8 +320,8 @@ a:hover .hero-on-hover { } a:hover .hero-caption { + text-decoration: underline; color: var(--md-typeset-btn-color); - font-weight: bold; } /* code badge */