This commit is contained in:
krahets 2023-04-13 22:45:38 +08:00
parent df51fb3ba3
commit 68dc078761
5 changed files with 58 additions and 58 deletions

View file

@ -1741,7 +1741,7 @@
<h1 id="118">11.8. &nbsp; 基数排序<a class="headerlink" href="#118" title="Permanent link">&para;</a></h1> <h1 id="118">11.8. &nbsp; 基数排序<a class="headerlink" href="#118" title="Permanent link">&para;</a></h1>
<p>上一节我们介绍了计数排序,它适用于数据量 <span class="arithmatex">\(n\)</span> 较大但数据范围 <span class="arithmatex">\(m\)</span> 较小的情况。假设我们需要对 <span class="arithmatex">\(n = 10^6\)</span> 个学号进行排序,而学号是一个 <span class="arithmatex">\(8\)</span> 位数字,这意味着数据范围 <span class="arithmatex">\(m = 10^8\)</span> 非常大,使用计数排序需要分配大量内存空间,而基数排序可以避免这种情况。</p> <p>上一节我们介绍了计数排序,它适用于数据量 <span class="arithmatex">\(n\)</span> 较大但数据范围 <span class="arithmatex">\(m\)</span> 较小的情况。假设我们需要对 <span class="arithmatex">\(n = 10^6\)</span> 个学号进行排序,而学号是一个 <span class="arithmatex">\(8\)</span> 位数字,这意味着数据范围 <span class="arithmatex">\(m = 10^8\)</span> 非常大,使用计数排序需要分配大量内存空间,而基数排序可以避免这种情况。</p>
<p>「基数排序 Radix Sort」的核心思想与计数排序一致也通过统计个数来实现排序。在此基础上基数排序利用数字各位之间的递进关系依次对每一位进行排序**,从而得到最终的排序结果。</p> <p>「基数排序 Radix Sort」的核心思想与计数排序一致也通过统计个数来实现排序。在此基础上基数排序利用数字各位之间的递进关系依次对每一位进行排序从而得到最终的排序结果。</p>
<h2 id="1181">11.8.1. &nbsp; 算法流程<a class="headerlink" href="#1181" title="Permanent link">&para;</a></h2> <h2 id="1181">11.8.1. &nbsp; 算法流程<a class="headerlink" href="#1181" title="Permanent link">&para;</a></h2>
<p>以学号数据为例,假设数字的最低位是第 <span class="arithmatex">\(1\)</span> 位,最高位是第 <span class="arithmatex">\(8\)</span> 位,基数排序的步骤如下:</p> <p>以学号数据为例,假设数字的最低位是第 <span class="arithmatex">\(1\)</span> 位,最高位是第 <span class="arithmatex">\(8\)</span> 位,基数排序的步骤如下:</p>
<ol> <ol>

View file

@ -2241,8 +2241,8 @@
<li>完美二叉树是理想情况,可以充分发挥二叉树“分治”的优势;</li> <li>完美二叉树是理想情况,可以充分发挥二叉树“分治”的优势;</li>
<li>链表则是另一个极端,各项操作都变为线性操作,时间复杂度退化至 <span class="arithmatex">\(O(n)\)</span> </li> <li>链表则是另一个极端,各项操作都变为线性操作,时间复杂度退化至 <span class="arithmatex">\(O(n)\)</span> </li>
</ul> </ul>
<p><img alt="二叉树的最佳与最二叉树的最佳和最差结构差情况" src="../binary_tree.assets/binary_tree_corner_cases.png" /></p> <p><img alt="二叉树的最佳与最差结构" src="../binary_tree.assets/binary_tree_corner_cases.png" /></p>
<p align="center"> Fig. 二叉树的最佳与最二叉树的最佳和最差结构差情况 </p> <p align="center"> Fig. 二叉树的最佳与最差结构 </p>
<p>如下表所示,在最佳和最差结构下,二叉树的叶节点数量、节点总数、高度等达到极大或极小值。</p> <p>如下表所示,在最佳和最差结构下,二叉树的叶节点数量、节点总数、高度等达到极大或极小值。</p>
<div class="center-table"> <div class="center-table">

File diff suppressed because one or more lines are too long

View file

@ -2,272 +2,272 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url> <url>
<loc>https://www.hello-algo.com/</loc> <loc>https://www.hello-algo.com/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc> <loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_appendix/installation/</loc> <loc>https://www.hello-algo.com/chapter_appendix/installation/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_time_tradeoff/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/space_time_tradeoff/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/data_and_memory/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/data_and_memory/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/graph/</loc> <loc>https://www.hello-algo.com/chapter_graph/graph/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc> <loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc> <loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/summary/</loc> <loc>https://www.hello-algo.com/chapter_graph/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc> <loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc> <loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/summary/</loc> <loc>https://www.hello-algo.com/chapter_hashing/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc> <loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/heap/</loc> <loc>https://www.hello-algo.com/chapter_heap/heap/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/summary/</loc> <loc>https://www.hello-algo.com/chapter_heap/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc> <loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/summary/</loc> <loc>https://www.hello-algo.com/chapter_introduction/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc> <loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc> <loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc> <loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/summary/</loc> <loc>https://www.hello-algo.com/chapter_preface/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_reference/</loc> <loc>https://www.hello-algo.com/chapter_reference/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc> <loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/hashing_search/</loc> <loc>https://www.hello-algo.com/chapter_searching/hashing_search/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/linear_search/</loc> <loc>https://www.hello-algo.com/chapter_searching/linear_search/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/summary/</loc> <loc>https://www.hello-algo.com/chapter_searching/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/bucket_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/bucket_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/counting_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/counting_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/intro_to_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/intro_to_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/radix_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/radix_sort/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/summary/</loc> <loc>https://www.hello-algo.com/chapter_sorting/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc> <loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/summary/</loc> <loc>https://www.hello-algo.com/chapter_tree/summary/</loc>
<lastmod>2023-04-10</lastmod> <lastmod>2023-04-13</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
</urlset> </urlset>

Binary file not shown.