⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page512.html

📁 Data Structures And Algorithms With Object-Oriented Design Patterns In Python (2003) source code and
💻 HTML
字号:
<HTML><HEAD><TITLE>Bucket Sort</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html7053" HREF="page513.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7051" HREF="page511.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7045" HREF="page511.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html7055" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION0015810000000000000000">Bucket Sort</A></H2><A NAME="secsortingbucket">&#160;</A><P>Bucket sort is possibly the simplest distribution sorting algorithm.The essential requirement is that the size of the universefrom which the elements to be sorted are drawnis a small, fixed constant, say <I>m</I>.<P>For example, suppose that we are sortingelements drawn from  <IMG WIDTH=114 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline69767" SRC="img2102.gif"  >,i.e., the set of integers in the interval [0,<I>m</I>-1].Bucket sort uses <I>m</I> counters.The  <IMG WIDTH=17 HEIGHT=14 ALIGN=BOTTOM ALT="tex2html_wrap_inline57847" SRC="img77.gif"  > counter keeps track of the number of occurrencesof the  <IMG WIDTH=17 HEIGHT=14 ALIGN=BOTTOM ALT="tex2html_wrap_inline57847" SRC="img77.gif"  > element of the universe.Figure&nbsp;<A HREF="page512.html#figsort8"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> illustrates how this is done.<P><P><A NAME="45364">&#160;</A><A NAME="figsort8">&#160;</A> <IMG WIDTH=575 HEIGHT=182 ALIGN=BOTTOM ALT="figure45006" SRC="img2103.gif"  ><BR><STRONG>Figure:</STRONG> Bucket sorting.<BR><P><P>In Figure&nbsp;<A HREF="page512.html#figsort8"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>, the universal set is assumed to be  <IMG WIDTH=80 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline69777" SRC="img2104.gif"  >.Therefore, ten counters are required--one to keep track of the number of zeroes,one to keep track of the number of ones, and so on.A single pass through the data suffices to countall of the elements.Once the counts have been determined,the sorted sequence is easily obtained.For example, the sorted sequence contains no zeroes,two ones, one two, and so on.<P><BR> <HR><UL> <LI> <A NAME="tex2html7056" HREF="page513.html#SECTION0015811000000000000000">Implementation</A></UL><HR><A NAME="tex2html7053" HREF="page513.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7051" HREF="page511.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7045" HREF="page511.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html7055" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright &#169; 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a>  All rights reserved.</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -