mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-23 16:47:13 +00:00
build
This commit is contained in:
+11
-11
@@ -16,7 +16,7 @@ comments: true
|
||||
|
||||
此方法只适用于 $k \ll n$ 的情况,因为当 $k$ 与 $n$ 比较接近时,其时间复杂度趋向于 $O(n^2)$ ,非常耗时。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 8-6 遍历寻找最大的 k 个元素 </p>
|
||||
|
||||
@@ -30,7 +30,7 @@ comments: true
|
||||
|
||||
显然,该方法“超额”完成任务了,因为我们只需要找出最大的 $k$ 个元素即可,而不需要排序其他元素。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 8-7 排序寻找最大的 k 个元素 </p>
|
||||
|
||||
@@ -44,31 +44,31 @@ comments: true
|
||||
4. 遍历完成后,堆中保存的就是最大的 $k$ 个元素。
|
||||
|
||||
=== "<1>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<2>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<3>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<4>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<5>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<6>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<7>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<8>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<9>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 8-8 基于堆寻找最大的 k 个元素 </p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user