mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-12 15:36:05 +00:00
deploy
This commit is contained in:
@@ -3426,7 +3426,7 @@
|
||||
|
||||
|
||||
<h1 id="114">11.4 插入排序<a class="headerlink" href="#114" title="Permanent link">¶</a></h1>
|
||||
<p>「插入排序 Insertion Sort」是一种简单的排序算法,它的工作原理与手动整理一副牌的过程非常相似。</p>
|
||||
<p>「插入排序 insertion sort」是一种简单的排序算法,它的工作原理与手动整理一副牌的过程非常相似。</p>
|
||||
<p>具体来说,我们在未排序区间选择一个基准元素,将该元素与其左侧已排序区间的元素逐一比较大小,并将该元素插入到正确的位置。</p>
|
||||
<p>回忆数组的元素插入操作,设基准元素为 <code>base</code> ,我们需要将从目标索引到 <code>base</code> 之间的所有元素向右移动一位,然后再将 <code>base</code> 赋值给目标索引。</p>
|
||||
<p><img alt="单次插入操作" src="../insertion_sort.assets/insertion_operation.png" /></p>
|
||||
|
||||
Reference in New Issue
Block a user