This commit is contained in:
krahets 2023-03-26 22:05:43 +08:00
parent d57f488347
commit 5901ac43e7
59 changed files with 3597 additions and 425 deletions

View file

@ -1348,6 +1348,8 @@
@ -1439,8 +1441,8 @@
<li class="md-nav__item">
<a href="/chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="/chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1453,8 +1455,22 @@
<li class="md-nav__item">
<a href="/chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="/chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="/chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1468,7 +1484,7 @@
<li class="md-nav__item">
<a href="/chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1359,6 +1359,8 @@
@ -1450,8 +1452,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1464,8 +1466,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1479,7 +1495,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1359,6 +1359,8 @@
@ -1450,8 +1452,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1464,8 +1466,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1479,7 +1495,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -1942,7 +1958,7 @@
<nav class="md-footer__inner md-grid" aria-label="页脚" >
<a href="../../chapter_sorting/summary/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.8. &amp;nbsp; 小结" rel="prev">
<a href="../../chapter_sorting/summary/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.9. &amp;nbsp; 小结" rel="prev">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
@ -1951,7 +1967,7 @@
<span class="md-footer__direction">
上一页
</span>
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</div>
</div>
</a>

View file

@ -1423,6 +1423,8 @@
@ -1514,8 +1516,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1528,8 +1530,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1543,7 +1559,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1423,6 +1423,8 @@
@ -1514,8 +1516,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1528,8 +1530,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1543,7 +1559,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1409,6 +1409,8 @@
@ -1500,8 +1502,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1514,8 +1516,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1529,7 +1545,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1436,6 +1436,8 @@
@ -1527,8 +1529,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1541,8 +1543,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1556,7 +1572,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1457,6 +1457,8 @@
@ -1548,8 +1550,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1562,8 +1564,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1577,7 +1593,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1422,6 +1422,8 @@
@ -1513,8 +1515,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1527,8 +1529,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1542,7 +1558,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1416,6 +1416,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1512,6 +1512,8 @@
@ -1603,8 +1605,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1617,8 +1619,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1632,7 +1648,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1409,6 +1409,8 @@
@ -1500,8 +1502,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1514,8 +1516,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1529,7 +1545,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1436,6 +1436,8 @@
@ -1527,8 +1529,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1541,8 +1543,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1556,7 +1572,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1443,6 +1443,8 @@
@ -1534,8 +1536,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1548,8 +1550,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1563,7 +1579,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1416,6 +1416,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1449,6 +1449,8 @@
@ -1540,8 +1542,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1554,8 +1556,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1569,7 +1585,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1436,6 +1436,8 @@
@ -1527,8 +1529,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1541,8 +1543,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1556,7 +1572,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1423,6 +1423,8 @@
@ -1514,8 +1516,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1528,8 +1530,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1543,7 +1559,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1429,6 +1429,8 @@
@ -1520,8 +1522,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1534,8 +1536,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1549,7 +1565,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1457,6 +1457,8 @@
@ -1548,8 +1550,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1562,8 +1564,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1577,7 +1593,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1416,6 +1416,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1414,6 +1414,8 @@
@ -1505,8 +1507,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1519,8 +1521,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1534,7 +1550,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1430,6 +1430,8 @@
@ -1521,8 +1523,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1535,8 +1537,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1550,7 +1566,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1357,6 +1357,8 @@
@ -1448,8 +1450,8 @@
<li class="md-nav__item">
<a href="../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1462,8 +1464,22 @@
<li class="md-nav__item">
<a href="../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1477,7 +1493,7 @@
<li class="md-nav__item">
<a href="../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1450,6 +1450,8 @@
@ -1541,8 +1543,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1555,8 +1557,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1570,7 +1586,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1416,6 +1416,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1416,6 +1416,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1361,6 +1361,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -15,17 +15,17 @@
<link rel="canonical" href="https://www.hello-algo.com/chapter_sorting/bucket_sort/">
<link rel="prev" href="../counting_sort/">
<link rel="prev" href="../merge_sort/">
<link rel="next" href="../summary/">
<link rel="next" href="../counting_sort/">
<link rel="icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.4.2, mkdocs-material-9.1.1">
<title>11.7.   桶排序New - Hello 算法</title>
<title>11.6.   桶排序New - Hello 算法</title>
@ -79,7 +79,7 @@
<div data-md-component="skip">
<a href="#117" class="md-skip">
<a href="#116" class="md-skip">
跳转至
</a>
@ -113,7 +113,7 @@
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
11.7. &nbsp; 桶排序New
11.6. &nbsp; 桶排序New
</span>
</div>
@ -1361,6 +1361,8 @@
@ -1450,20 +1452,6 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
</a>
</li>
@ -1476,12 +1464,12 @@
<label class="md-nav__link md-nav__link--active" for="__toc">
11.7. &nbsp; 桶排序New
11.6. &nbsp; 桶排序New
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
11.7. &nbsp; 桶排序New
11.6. &nbsp; 桶排序New
</a>
@ -1500,22 +1488,22 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1171" class="md-nav__link">
11.7.1. &nbsp; 算法流程
<a href="#1161" class="md-nav__link">
11.6.1. &nbsp; 算法流程
</a>
</li>
<li class="md-nav__item">
<a href="#1172" class="md-nav__link">
11.7.2. &nbsp; 算法特性
<a href="#1162" class="md-nav__link">
11.6.2. &nbsp; 算法特性
</a>
</li>
<li class="md-nav__item">
<a href="#1173" class="md-nav__link">
11.7.3. &nbsp; 如何实现平均分配
<a href="#1163" class="md-nav__link">
11.6.3. &nbsp; 如何实现平均分配
</a>
</li>
@ -1534,9 +1522,37 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -1694,22 +1710,22 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1171" class="md-nav__link">
11.7.1. &nbsp; 算法流程
<a href="#1161" class="md-nav__link">
11.6.1. &nbsp; 算法流程
</a>
</li>
<li class="md-nav__item">
<a href="#1172" class="md-nav__link">
11.7.2. &nbsp; 算法特性
<a href="#1162" class="md-nav__link">
11.6.2. &nbsp; 算法特性
</a>
</li>
<li class="md-nav__item">
<a href="#1173" class="md-nav__link">
11.7.3. &nbsp; 如何实现平均分配
<a href="#1163" class="md-nav__link">
11.6.3. &nbsp; 如何实现平均分配
</a>
</li>
@ -1737,9 +1753,10 @@
<h1 id="117">11.7. &nbsp; 桶排序<a class="headerlink" href="#117" title="Permanent link">&para;</a></h1>
<p>「桶排序 Bucket Sort」是分治思想的典型体现其通过设置一些桶将数据平均分配到各个桶中并在每个桶内部分别执行排序最终根据桶之间天然的大小顺序将各个桶内元素合并从而得到排序结果。</p>
<h2 id="1171">11.7.1. &nbsp; 算法流程<a class="headerlink" href="#1171" title="Permanent link">&para;</a></h2>
<h1 id="116">11.6. &nbsp; 桶排序<a class="headerlink" href="#116" title="Permanent link">&para;</a></h1>
<p>前面介绍的几种排序算法都属于 <strong>基于比较的排序算法</strong>,即通过比较元素之间的大小来实现排序,此类排序算法的时间复杂度无法超越 <span class="arithmatex">\(O(n \log n)\)</span> 。接下来,我们将学习几种 <strong>非比较排序算法</strong> ,其时间复杂度可以达到线性级别。</p>
<p>「桶排序 Bucket Sort」是分治思想的典型体现其通过设置一些具有大小顺序的桶每个桶对应一个数据范围将数据平均分配到各个桶中并在每个桶内部分别执行排序最终按照桶的顺序将所有数据合并即可。</p>
<h2 id="1161">11.6.1. &nbsp; 算法流程<a class="headerlink" href="#1161" title="Permanent link">&para;</a></h2>
<p>输入一个长度为 <span class="arithmatex">\(n\)</span> 的数组,元素是范围 <span class="arithmatex">\([0, 1)\)</span> 的浮点数,桶排序流程为:</p>
<ol>
<li>初始化 <span class="arithmatex">\(k\)</span> 个桶,将 <span class="arithmatex">\(n\)</span> 个元素分配至 <span class="arithmatex">\(k\)</span> 个桶中;</li>
@ -1820,16 +1837,16 @@
</div>
</div>
</div>
<div class="admonition note">
<p class="admonition-title">桶排序是计数排序的一种推广</p>
<p>从桶排序的角度,我们可以把计数排序中计数数组 <code>counter</code> 的每个索引想象成一个桶,将统计数量的过程想象成把各个元素分配到对应的桶中,再根据桶之间的有序性输出结果,从而实现排序</p>
<div class="admonition question">
<p class="admonition-title">桶排序的应用场景是什么?</p>
<p>桶排序一般用于排序超大体量的数据。例如输入数据包含 100 万个元素,由于空间有限,系统无法一次性将所有数据加载进内存,那么可以先将数据划分到 1000 个桶里,再依次排序每个桶,最终合并结果即可</p>
</div>
<h2 id="1172">11.7.2. &nbsp; 算法特性<a class="headerlink" href="#1172" title="Permanent link">&para;</a></h2>
<h2 id="1162">11.6.2. &nbsp; 算法特性<a class="headerlink" href="#1162" title="Permanent link">&para;</a></h2>
<p><strong>时间复杂度 <span class="arithmatex">\(O(n + k)\)</span></strong> :假设元素平均分布在各个桶内,则每个桶内元素数量为 <span class="arithmatex">\(\frac{n}{k}\)</span> 。假设排序单个桶使用 <span class="arithmatex">\(O(\frac{n}{k} \log\frac{n}{k})\)</span> 时间,则排序所有桶使用 <span class="arithmatex">\(O(n \log\frac{n}{k})\)</span> 时间,<strong>当桶数量 <span class="arithmatex">\(k\)</span> 比较大时,时间复杂度则趋向于 <span class="arithmatex">\(O(n)\)</span></strong> 。最后合并结果需要遍历 <span class="arithmatex">\(n\)</span> 个桶,使用 <span class="arithmatex">\(O(k)\)</span> 时间。</p>
<p>最差情况下,所有数据被分配到一个桶中,且排序算法退化至 <span class="arithmatex">\(O(n^2)\)</span> ,此时使用 <span class="arithmatex">\(O(n^2)\)</span> 时间,因此是“自适应排序”。</p>
<p><strong>空间复杂度 <span class="arithmatex">\(O(n + k)\)</span></strong> :需要借助 <span class="arithmatex">\(k\)</span> 个桶和共 <span class="arithmatex">\(n\)</span> 个元素的额外空间,是“非原地排序”。</p>
<p>桶排序是否稳定取决于排序桶内元素的算法是否稳定。</p>
<h2 id="1173">11.7.3. &nbsp; 如何实现平均分配<a class="headerlink" href="#1173" title="Permanent link">&para;</a></h2>
<h2 id="1163">11.6.3. &nbsp; 如何实现平均分配<a class="headerlink" href="#1163" title="Permanent link">&para;</a></h2>
<p>桶排序的时间复杂度理论上可以达到 <span class="arithmatex">\(O(n)\)</span> <strong>难点是需要将元素均匀分配到各个桶中</strong>,因为现实中的数据往往都不是均匀分布的。举个例子,假设我们想要把淘宝的所有商品根据价格范围平均分配到 10 个桶中然而商品价格不是均匀分布的100 元以下非常多、1000 元以上非常少;如果我们将价格区间平均划为 10 份,那么各个桶内的商品数量差距会非常大。</p>
<p>为了实现平均分配,我们可以先大致设置一个分界线,将数据粗略分到 3 个桶,分配完后,<strong>再把商品较多的桶继续划分为 3 个桶,直至所有桶内元素数量大致平均为止</strong>。此方法本质上是生成一个递归树,让叶结点的值尽量平均。当然,不一定非要划分为 3 个桶,可以根据数据特点灵活选取。</p>
<p><img alt="递归划分桶" src="../bucket_sort.assets/scatter_in_buckets_recursively.png" /></p>
@ -1915,7 +1932,7 @@
<nav class="md-footer__inner md-grid" aria-label="页脚" >
<a href="../counting_sort/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.6. &amp;nbsp; 计数排序New" rel="prev">
<a href="../merge_sort/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.5. &amp;nbsp; 归并排序" rel="prev">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
@ -1924,20 +1941,20 @@
<span class="md-footer__direction">
上一页
</span>
11.6. &nbsp; 计数排序New
11.5. &nbsp; 归并排序
</div>
</div>
</a>
<a href="../summary/" class="md-footer__link md-footer__link--next" aria-label="下一页: 11.8. &amp;nbsp; 小结" rel="next">
<a href="../counting_sort/" class="md-footer__link md-footer__link--next" aria-label="下一页: 11.7. &amp;nbsp; 计数排序New" rel="next">
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
下一页
</span>
11.8. &nbsp; 小结
11.7. &nbsp; 计数排序New
</div>
</div>
<div class="md-footer__button md-icon">

View file

@ -15,17 +15,17 @@
<link rel="canonical" href="https://www.hello-algo.com/chapter_sorting/counting_sort/">
<link rel="prev" href="../merge_sort/">
<link rel="prev" href="../bucket_sort/">
<link rel="next" href="../bucket_sort/">
<link rel="next" href="../radix_sort/">
<link rel="icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.4.2, mkdocs-material-9.1.1">
<title>11.6.   计数排序New - Hello 算法</title>
<title>11.7.   计数排序New - Hello 算法</title>
@ -79,7 +79,7 @@
<div data-md-component="skip">
<a href="#116" class="md-skip">
<a href="#117" class="md-skip">
跳转至
</a>
@ -113,7 +113,7 @@
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
11.6. &nbsp; 计数排序New
11.7. &nbsp; 计数排序New
</span>
</div>
@ -1361,6 +1361,8 @@
@ -1450,6 +1452,20 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 桶排序New
</a>
</li>
@ -1462,12 +1478,12 @@
<label class="md-nav__link md-nav__link--active" for="__toc">
11.6. &nbsp; 计数排序New
11.7. &nbsp; 计数排序New
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
11.6. &nbsp; 计数排序New
11.7. &nbsp; 计数排序New
</a>
@ -1486,29 +1502,29 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1161" class="md-nav__link">
11.6.1. &nbsp; 简单实现
<a href="#1171" class="md-nav__link">
11.7.1. &nbsp; 简单实现
</a>
</li>
<li class="md-nav__item">
<a href="#1162" class="md-nav__link">
11.6.2. &nbsp; 完整实现
<a href="#1172" class="md-nav__link">
11.7.2. &nbsp; 完整实现
</a>
</li>
<li class="md-nav__item">
<a href="#1163" class="md-nav__link">
11.6.3. &nbsp; 算法特性
<a href="#1173" class="md-nav__link">
11.7.3. &nbsp; 算法特性
</a>
</li>
<li class="md-nav__item">
<a href="#1164" class="md-nav__link">
11.6.4. &nbsp; 局限性
<a href="#1174" class="md-nav__link">
11.7.4. &nbsp; 局限性
</a>
</li>
@ -1528,8 +1544,8 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp;排序New
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1543,7 +1559,7 @@
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -1701,29 +1717,29 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1161" class="md-nav__link">
11.6.1. &nbsp; 简单实现
<a href="#1171" class="md-nav__link">
11.7.1. &nbsp; 简单实现
</a>
</li>
<li class="md-nav__item">
<a href="#1162" class="md-nav__link">
11.6.2. &nbsp; 完整实现
<a href="#1172" class="md-nav__link">
11.7.2. &nbsp; 完整实现
</a>
</li>
<li class="md-nav__item">
<a href="#1163" class="md-nav__link">
11.6.3. &nbsp; 算法特性
<a href="#1173" class="md-nav__link">
11.7.3. &nbsp; 算法特性
</a>
</li>
<li class="md-nav__item">
<a href="#1164" class="md-nav__link">
11.6.4. &nbsp; 局限性
<a href="#1174" class="md-nav__link">
11.7.4. &nbsp; 局限性
</a>
</li>
@ -1751,16 +1767,15 @@
<h1 id="116">11.6. &nbsp; 计数排序<a class="headerlink" href="#116" title="Permanent link">&para;</a></h1>
<p>前面介绍的几种排序算法都属于 <strong>基于比较的排序算法</strong>,即通过比较元素之间的大小来实现排序,此类排序算法的时间复杂度无法超越 <span class="arithmatex">\(O(n \log n)\)</span> 。接下来,我们将学习一种 <strong>非比较排序算法</strong> ,名为「计数排序 Counting Sort」其时间复杂度可以达到 <span class="arithmatex">\(O(n)\)</span> </p>
<h2 id="1161">11.6.1. &nbsp; 简单实现<a class="headerlink" href="#1161" title="Permanent link">&para;</a></h2>
<h1 id="117">11.7. &nbsp; 计数排序<a class="headerlink" href="#117" title="Permanent link">&para;</a></h1>
<p>顾名思义,「计数排序 Counting Sort」通过统计元素数量来实现排序一般应用于整数数组</p>
<h2 id="1171">11.7.1. &nbsp; 简单实现<a class="headerlink" href="#1171" title="Permanent link">&para;</a></h2>
<p>先看一个简单例子。给定一个长度为 <span class="arithmatex">\(n\)</span> 的数组 <code>nums</code> ,元素皆为 <strong>非负整数</strong>。计数排序的整体流程为:</p>
<ol>
<li>遍历记录数组中的最大数字,记为 <span class="arithmatex">\(m\)</span> ,并建立一个长度为 <span class="arithmatex">\(m + 1\)</span> 的辅助数组 <code>counter</code> </li>
<li><strong>借助 <code>counter</code> 统计 <code>nums</code> 中各数字的出现次数</strong>,其中 <code>counter[num]</code> 对应数字 <code>num</code> 的出现次数。统计方法很简单,只需遍历 <code>nums</code> (设当前数字为 <code>num</code>),每轮将 <code>counter[num]</code> 自增 <span class="arithmatex">\(1\)</span> 即可。</li>
<li><strong>由于 <code>counter</code> 的各个索引是天然有序的,因此相当于所有数字已经被排序好了</strong>。接下来,我们遍历 <code>counter</code> ,根据各数字的出现次数,将各数字按从小到大的顺序填入 <code>nums</code> 即可。</li>
</ol>
<p>观察发现,计数排序名副其实,是通过“统计元素数量”来实现排序的。</p>
<p><img alt="计数排序流程" src="../counting_sort.assets/counting_sort_overview.png" /></p>
<p align="center"> Fig. 计数排序流程 </p>
@ -1909,7 +1924,11 @@
</div>
</div>
</div>
<h2 id="1162">11.6.2. &nbsp; 完整实现<a class="headerlink" href="#1162" title="Permanent link">&para;</a></h2>
<div class="admonition note">
<p class="admonition-title">计数排序与桶排序的联系</p>
<p>从桶排序的角度看,我们可以把计数排序中计数数组 <code>counter</code> 的每个索引想象成一个桶,将统计数量的过程想象成把各个元素分配到对应的桶中。本质上,计数排序是桶排序在整型数据下的一个特例。</p>
</div>
<h2 id="1172">11.7.2. &nbsp; 完整实现<a class="headerlink" href="#1172" title="Permanent link">&para;</a></h2>
<p>细心的同学可能发现,<strong>如果输入数据是对象,上述步骤 <code>3.</code> 就失效了</strong>。例如输入数据是商品对象,我们想要按照商品价格(类的成员变量)对商品进行排序,而上述算法只能给出价格的排序结果。</p>
<p>那么如何才能得到原数据的排序结果呢?我们首先计算 <code>counter</code> 的「前缀和」,顾名思义,索引 <code>i</code> 处的前缀和 <code>prefix[i]</code> 等于数组前 <code>i</code> 个元素之和,即</p>
<div class="arithmatex">\[
@ -2142,14 +2161,14 @@
</div>
</div>
</div>
<h2 id="1163">11.6.3. &nbsp; 算法特性<a class="headerlink" href="#1163" title="Permanent link">&para;</a></h2>
<h2 id="1173">11.7.3. &nbsp; 算法特性<a class="headerlink" href="#1173" title="Permanent link">&para;</a></h2>
<p><strong>时间复杂度 <span class="arithmatex">\(O(n + m)\)</span></strong> :涉及遍历 <code>nums</code> 和遍历 <code>counter</code> ,都使用线性时间。一般情况下 <span class="arithmatex">\(n \gg m\)</span> ,此时使用线性 <span class="arithmatex">\(O(n)\)</span> 时间。</p>
<p><strong>空间复杂度 <span class="arithmatex">\(O(n + m)\)</span></strong> :借助了长度分别为 <span class="arithmatex">\(n\)</span> , <span class="arithmatex">\(m\)</span> 的数组 <code>res</code><code>counter</code> ,是“非原地排序”</p>
<p><strong>空间复杂度 <span class="arithmatex">\(O(n + m)\)</span></strong> :借助了长度分别为 <span class="arithmatex">\(n\)</span> , <span class="arithmatex">\(m\)</span> 的数组 <code>res</code><code>counter</code> ,是“非原地排序”</p>
<p><strong>稳定排序</strong>:由于向 <code>res</code> 中填充元素的顺序是“从右向左”的,因此倒序遍历 <code>nums</code> 可以避免改变相等元素之间的相对位置,从而实现“稳定排序”;其实正序遍历 <code>nums</code> 也可以得到正确的排序结果,但结果“非稳定”。</p>
<h2 id="1164">11.6.4. &nbsp; 局限性<a class="headerlink" href="#1164" title="Permanent link">&para;</a></h2>
<h2 id="1174">11.7.4. &nbsp; 局限性<a class="headerlink" href="#1174" title="Permanent link">&para;</a></h2>
<p>看到这里,你也许会觉得计数排序太妙了,咔咔一通操作,时间复杂度就下来了。然而,使用技术排序的前置条件比较苛刻。</p>
<p><strong>计数排序只适用于非负整数</strong>。若想要用在其他类型数据上,则要求该数据必须可以被转化为非负整数,并且不能改变各个元素之间的相对大小关系。例如,对于包含负数的整数数组,可以先给所有数字加上一个常数,将全部数字转化为正数,排序完成后再转换回去即可。</p>
<p><strong>计数排序适用于数据范围不大的情况</strong>。比如,上述示例中 <span class="arithmatex">\(m\)</span> 不能太大,否则占用空间太多;而当 <span class="arithmatex">\(n \ll m\)</span> 时,计数排序使用 <span class="arithmatex">\(O(m)\)</span> 时间,有可能比 <span class="arithmatex">\(O(n \log n)\)</span> 的排序算法还要慢。</p>
<p><strong>计数排序适用于数据量大但数据范围不大的情况</strong>。比如,上述示例中 <span class="arithmatex">\(m\)</span> 不能太大,否则占用空间太多;而当 <span class="arithmatex">\(n \ll m\)</span> 时,计数排序使用 <span class="arithmatex">\(O(m)\)</span> 时间,有可能比 <span class="arithmatex">\(O(n \log n)\)</span> 的排序算法还要慢。</p>
@ -2227,7 +2246,7 @@
<nav class="md-footer__inner md-grid" aria-label="页脚" >
<a href="../merge_sort/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.5. &amp;nbsp; 归并排序" rel="prev">
<a href="../bucket_sort/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.6. &amp;nbsp; 桶排序New" rel="prev">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
@ -2236,20 +2255,20 @@
<span class="md-footer__direction">
上一页
</span>
11.5. &nbsp; 归并排序
11.6. &nbsp; 桶排序New
</div>
</div>
</a>
<a href="../bucket_sort/" class="md-footer__link md-footer__link--next" aria-label="下一页: 11.7. &amp;nbsp; 桶排序New" rel="next">
<a href="../radix_sort/" class="md-footer__link md-footer__link--next" aria-label="下一页: 11.8. &amp;nbsp; 基数排序New" rel="next">
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
下一页
</span>
11.7. &nbsp;排序New
11.8. &nbsp; 基数排序New
</div>
</div>
<div class="md-footer__button md-icon">

View file

@ -1361,6 +1361,8 @@
@ -1458,8 +1460,8 @@
</li>
<li class="md-nav__item">
<a href="#1133-vs" class="md-nav__link">
11.3.3. &nbsp; 插入排序 vs 冒泡排序
<a href="#1133" class="md-nav__link">
11.3.3. &nbsp; 插入排序优势
</a>
</li>
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -1708,8 +1724,8 @@
</li>
<li class="md-nav__item">
<a href="#1133-vs" class="md-nav__link">
11.3.3. &nbsp; 插入排序 vs 冒泡排序
<a href="#1133" class="md-nav__link">
11.3.3. &nbsp; 插入排序优势
</a>
</li>
@ -1915,18 +1931,18 @@
<p><strong>时间复杂度 <span class="arithmatex">\(O(n^2)\)</span></strong> :最差情况下,各轮插入操作循环 <span class="arithmatex">\(n - 1\)</span> , <span class="arithmatex">\(n-2\)</span> , <span class="arithmatex">\(\cdots\)</span> , <span class="arithmatex">\(2\)</span> , <span class="arithmatex">\(1\)</span> 次,求和为 <span class="arithmatex">\(\frac{(n - 1) n}{2}\)</span> ,使用 <span class="arithmatex">\(O(n^2)\)</span> 时间。输入数组完全有序下,达到最佳时间复杂度 <span class="arithmatex">\(O(n)\)</span> ,因此是“自适应排序”。</p>
<p><strong>空间复杂度 <span class="arithmatex">\(O(1)\)</span></strong> :指针 <span class="arithmatex">\(i\)</span> , <span class="arithmatex">\(j\)</span> 使用常数大小的额外空间,因此是“原地排序”。</p>
<p>在插入操作中,我们会将元素插入到相等元素的右边,不会改变它们的次序,因此是“稳定排序”。</p>
<h2 id="1133-vs">11.3.3. &nbsp; 插入排序 vs 冒泡排序<a class="headerlink" href="#1133-vs" title="Permanent link">&para;</a></h2>
<h2 id="1133">11.3.3. &nbsp; 插入排序优势<a class="headerlink" href="#1133" title="Permanent link">&para;</a></h2>
<p>回顾「冒泡排序」和「插入排序」的复杂度分析,两者的循环轮数都是 <span class="arithmatex">\(\frac{(n - 1) n}{2}\)</span> 。但不同的是:</p>
<ul>
<li>冒泡操作基于 <strong>元素交换</strong> 实现,需要借助一个临时变量实现,共 3 个单元操作;</li>
<li>插入操作基于 <strong>元素赋值</strong> 实现,只需 1 个单元操作;</li>
</ul>
<p>因此,可以粗略估计出冒泡排序的计算开销约为插入排序的 3 倍,因此更受欢迎。实际上,许多编程语言(例如 Java的内置排序函数都使用到了插入排序大致思路为</p>
<p>粗略估计,冒泡排序的计算开销约为插入排序的 3 倍,因此插入排序更受欢迎,许多编程语言(例如 Java的内置排序函数都使用到了插入排序大致思路为</p>
<ul>
<li>对于 <strong>长数组</strong>,采用基于分治的排序算法,例如「快速排序」,时间复杂度为 <span class="arithmatex">\(O(n \log n)\)</span> </li>
<li>对于 <strong>短数组</strong>,直接使用「插入排序」,时间复杂度为 <span class="arithmatex">\(O(n^2)\)</span> </li>
</ul>
<p><strong>在数据量较小时插入排序更快</strong>,这是因为复杂度中的常数项(即每轮中的单元操作数量)占主导作用。这个现象与「线性查找」和「二分查找」的情况类似。</p>
<p>虽然插入排序比快速排序的时间复杂度更高,<strong>但实际上在数据量较小时插入排序更快</strong>,这是因为复杂度中的常数项(即每轮中的单元操作数量)占主导作用。这个现象与「线性查找」和「二分查找」的情况类似。</p>

View file

@ -1361,6 +1361,8 @@
@ -1534,8 +1536,8 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1548,8 +1550,22 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1563,7 +1579,7 @@
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -18,7 +18,7 @@
<link rel="prev" href="../quick_sort/">
<link rel="next" href="../counting_sort/">
<link rel="next" href="../bucket_sort/">
<link rel="icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.4.2, mkdocs-material-9.1.1">
@ -1361,6 +1361,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -2319,13 +2335,13 @@
<a href="../counting_sort/" class="md-footer__link md-footer__link--next" aria-label="下一页: 11.6. &amp;nbsp; 计数排序New" rel="next">
<a href="../bucket_sort/" class="md-footer__link md-footer__link--next" aria-label="下一页: 11.6. &amp;nbsp; 排序New" rel="next">
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
下一页
</span>
11.6. &nbsp; 计数排序New
11.6. &nbsp; 排序New
</div>
</div>
<div class="md-footer__button md-icon">

View file

@ -1361,6 +1361,8 @@
@ -1521,8 +1523,8 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1535,8 +1537,22 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1550,7 +1566,7 @@
<li class="md-nav__item">
<a href="../summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -2034,13 +2050,6 @@
</div>
</div>
</div>
<div class="admonition question">
<p class="admonition-title">“从右往左查找”与“从左往右查找”顺序可以交换吗?</p>
<p>不行,当我们以最左端元素为基准数时,必须先“从右往左查找”再“从左往右查找”。这个结论有些反直觉,我们来剖析一下原因。</p>
<p>哨兵划分 <code>partition()</code> 的最后一步是交换 <code>nums[left]</code><code>nums[i]</code> ,完成交换后,基准数左边的元素都 <code>&lt;=</code> 基准数,<strong>这就要求最后一步交换前 <code>nums[left] &gt;= nums[i]</code> 必须成立</strong>。假设我们先“从左往右查找”,那么如果找不到比基准数更小的元素,<strong>则会在 <code>i == j</code> 时跳出循环,此时可能 <code>nums[j] == nums[i] &gt; nums[left]</code></strong> ;也就是说,此时最后一步交换操作会把一个比基准数更大的元素交换至数组最左端,导致哨兵划分失败。</p>
<p>举个例子,给定数组 <code>[0, 0, 0, 0, 1]</code> ,如果先“从左向右查找”,哨兵划分后数组为 <code>[1, 0, 0, 0, 0]</code> ,这个结果是不对的。</p>
<p>再深想一步,如果我们选择 <code>nums[right]</code> 为基准数,那么正好反过来,必须先“从左往右查找”。</p>
</div>
<h2 id="1141">11.4.1. &nbsp; 算法流程<a class="headerlink" href="#1141" title="Permanent link">&para;</a></h2>
<ol>
<li>首先,对数组执行一次「哨兵划分」,得到待排序的 <strong>左子数组</strong><strong>右子数组</strong></li>
@ -2689,6 +2698,13 @@
</div>
</div>
</div>
<div class="admonition question">
<p class="admonition-title">哨兵划分中“从右往左查找”与“从左往右查找”的顺序可以交换吗?</p>
<p>不行,当我们以最左端元素为基准数时,必须先“从右往左查找”再“从左往右查找”。这个结论有些反直觉,我们来剖析一下原因。</p>
<p>哨兵划分 <code>partition()</code> 的最后一步是交换 <code>nums[left]</code><code>nums[i]</code> ,完成交换后,基准数左边的元素都 <code>&lt;=</code> 基准数,<strong>这就要求最后一步交换前 <code>nums[left] &gt;= nums[i]</code> 必须成立</strong>。假设我们先“从左往右查找”,那么如果找不到比基准数更小的元素,<strong>则会在 <code>i == j</code> 时跳出循环,此时可能 <code>nums[j] == nums[i] &gt; nums[left]</code></strong> ;也就是说,此时最后一步交换操作会把一个比基准数更大的元素交换至数组最左端,导致哨兵划分失败。</p>
<p>举个例子,给定数组 <code>[0, 0, 0, 0, 1]</code> ,如果先“从左向右查找”,哨兵划分后数组为 <code>[1, 0, 0, 0, 0]</code> ,这个结果是不对的。</p>
<p>再深想一步,如果我们选择 <code>nums[right]</code> 为基准数,那么正好反过来,必须先“从左往右查找”。</p>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@
<link rel="canonical" href="https://www.hello-algo.com/chapter_sorting/summary/">
<link rel="prev" href="../bucket_sort/">
<link rel="prev" href="../radix_sort/">
<link rel="next" href="../../chapter_appendix/installation/">
@ -25,7 +25,7 @@
<title>11.8.   小结 - Hello 算法</title>
<title>11.9.   小结 - Hello 算法</title>
@ -79,7 +79,7 @@
<div data-md-component="skip">
<a href="#118" class="md-skip">
<a href="#119" class="md-skip">
跳转至
</a>
@ -113,7 +113,7 @@
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</span>
</div>
@ -1361,6 +1361,8 @@
@ -1452,8 +1454,8 @@
<li class="md-nav__item">
<a href="../counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1466,8 +1468,22 @@
<li class="md-nav__item">
<a href="../bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1490,7 +1506,7 @@
<a href="./" class="md-nav__link md-nav__link--active">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>
@ -1663,7 +1679,7 @@
<h1 id="118">11.8. &nbsp; 小结<a class="headerlink" href="#118" title="Permanent link">&para;</a></h1>
<h1 id="119">11.9. &nbsp; 小结<a class="headerlink" href="#119" title="Permanent link">&para;</a></h1>
<ul>
<li>冒泡排序通过交换相邻元素来实现排序。通过增加标志位实现提前返回,我们可将冒泡排序的最佳时间复杂度优化至 <span class="arithmatex">\(O(N)\)</span></li>
<li>插入排序每轮将待排序区间内元素插入至已排序区间的正确位置,从而实现排序。插入排序的时间复杂度虽为 <span class="arithmatex">\(O(N^2)\)</span> ,但因为总体操作少而很受欢迎,一般用于小数据量的排序工作。</li>
@ -1754,7 +1770,7 @@
<nav class="md-footer__inner md-grid" aria-label="页脚" >
<a href="../bucket_sort/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.7. &amp;nbsp; 桶排序New" rel="prev">
<a href="../radix_sort/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 11.8. &amp;nbsp; 基数排序New" rel="prev">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
@ -1763,7 +1779,7 @@
<span class="md-footer__direction">
上一页
</span>
11.7. &nbsp;排序New
11.8. &nbsp; 基数排序New
</div>
</div>
</a>

View file

@ -1436,6 +1436,8 @@
@ -1527,8 +1529,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1541,8 +1543,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1556,7 +1572,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1443,6 +1443,8 @@
@ -1534,8 +1536,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1548,8 +1550,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1563,7 +1579,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1470,6 +1470,8 @@
@ -1561,8 +1563,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1575,8 +1577,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1590,7 +1606,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1371,6 +1371,8 @@
@ -1462,8 +1464,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1476,8 +1478,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1491,7 +1507,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1511,6 +1511,8 @@
@ -1602,8 +1604,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1616,8 +1618,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1631,7 +1647,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1457,6 +1457,8 @@
@ -1548,8 +1550,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1562,8 +1564,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1577,7 +1593,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1464,6 +1464,8 @@
@ -1555,8 +1557,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1569,8 +1571,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1584,7 +1600,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1449,6 +1449,8 @@
@ -1540,8 +1542,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1554,8 +1556,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1569,7 +1585,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1416,6 +1416,8 @@
@ -1507,8 +1509,8 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1521,8 +1523,22 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="../../chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="../../chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1536,7 +1552,7 @@
<li class="md-nav__item">
<a href="../../chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

View file

@ -1352,6 +1352,8 @@
@ -1443,8 +1445,8 @@
<li class="md-nav__item">
<a href="chapter_sorting/counting_sort/" class="md-nav__link">
11.6. &nbsp; 计数排序New
<a href="chapter_sorting/bucket_sort/" class="md-nav__link">
11.6. &nbsp; 排序New
</a>
</li>
@ -1457,8 +1459,22 @@
<li class="md-nav__item">
<a href="chapter_sorting/bucket_sort/" class="md-nav__link">
11.7. &nbsp; 桶排序New
<a href="chapter_sorting/counting_sort/" class="md-nav__link">
11.7. &nbsp; 计数排序New
</a>
</li>
<li class="md-nav__item">
<a href="chapter_sorting/radix_sort/" class="md-nav__link">
11.8. &nbsp; 基数排序New
</a>
</li>
@ -1472,7 +1488,7 @@
<li class="md-nav__item">
<a href="chapter_sorting/summary/" class="md-nav__link">
11.8. &nbsp; 小结
11.9. &nbsp; 小结
</a>
</li>

File diff suppressed because one or more lines are too long

View file

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

Binary file not shown.