Re: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>RedBot
m r2.7.2) (Robot: Adding lmo:Re (desambiguazion)
 
Correcting an incorrect WIKI page
Line 1: Line 1:
An underweight individual can have low immunity, reduced endurance, and a deficiency of vitamins in his body. So, fat control is pretty important. There are many methods to determine the ideal weight of the individual. Among them are, waist to height ratio, and height to weight ratio.<br><br>A popular diagnostic tool, the body mass index measures the body fat based on the fat plus [http://safedietplans.com/bmi-chart bmi chart] the height of an individual. Developed by a Belgian scientist Adolphe Quetelet, it helps to calculate how healthy a person is based on his fat plus identify whether the person is underweight, overweight, or obese. The relation of BMI to fatness differs for individuals of different age and gender. As an example, the BMI of females is likely to be higher than which of guys.<br><br>Consider these statistics in light of the truth more diet treatments exist than ever before. There are more health clubs and fitness centers than ever. More diet programs like Weight Watchers plus bmi chart men Nutri-system. More cosmetic procedures such as liposuction plus belly tuck. Medical rules like gastric bypass. Prescription diet medications along with a lot of over the counter treatments claiming fat reduction benefit. More information available for you than ever before. Yet, we get fatter and fatter because a nation, and now at epidemic degrees.<br><br>14.Running in Different types of Weather: I am not a treadmill runner, thus I can run inside anything brief of a blizzard. With the right levels of clothing this really is possible. However, should you are training in summer for a fall race, beware of weather differences. The weather throughout the race might be truly different then whenever you're training. Don't be disappointed in the event you are not able to run 17 miles the technique we think you should whenever you're inside 80-90 degree heat plus significant humidity.<br><br>Examples 1 and 2 show which an exponent of 3 is a bit more realistic than 2 for estimating the fat of the individual for a provided height. With all due modesty, I propose the Larry Index (LI) as a fair compromise, and as a realistic alternative to Ancel Keys' BMI.<br><br>BMI refuses to measure body fat straight bmi chart women, however, it relates carefully to direct measures of body fat. For adults, BMI is interpreted whilst factors including sex or age are not taken in account.<br><br>18. Type of Diet: Adhering to a well-balanced, low-fat, wholegrain diet which is higher in carbs has constantly been the greatest route for me. I love a superior smoothie (see post "Smoothie Operator --quick nutritional training meal") whilst training. Here's an interesting post w/ superior tips on eating from Cool Running called "The Runner's Diet".<br><br>If you are thinking what the healthy fat is for a woman, then the BMI is the path to take. You should also check the circumference of the waist. If you believe you're overweight, then we should commence eating healthy plus exercise regularly so that you can lose those pounds and be the healthy, brand-new we.
{{Infobox Algorithm
|class=[[Sorting algorithm]]
|image=
|data=[[Array data structure|Array]]
|time=<math>O(n^2)</math>
|average-time=<math>O(n+k)</math>
|space=<math>O(n\cdot k)</math>
|optimal= <math>O(''n'')</math>
}}
 
{{Expert-subject| Computer science|date=November 2008}}
[[Image:Bucket sort 1.png|right|frame|Elements are distributed among bins]]
[[Image:Bucket sort 2.png|right|frame|Then, elements are sorted within each bin]]
'''Bucket sort''', or '''bin sort''', is a [[sorting algorithm]] that works by partitioning an [[Array data structure|array]] into a number of [[bucket (computing)|bucket]]s. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a [[distribution sort]], and is a cousin of [[radix sort]] in the most to least significant digit flavour. Bucket sort is a generalization of [[pigeonhole sort]]. Since bucket sort is not a [[comparison sort]], the Ω(''n'' log ''n'') lower bound is inapplicable. The [[computational complexity]] estimates involve the number of buckets.
 
Bucket sort works as follows:
# Set up an array of initially empty "buckets".
# '''Scatter''': Go over the original array, putting each object in its bucket.
# Sort each non-empty bucket.
# '''Gather''': Visit the buckets in order and put all elements back into the original array.
 
==Pseudocode==
 
'''function''' bucketSort(array, n) '''is'''
  buckets ← new array of n empty lists
  '''for''' i = 0 '''to''' (length(array)-1) '''do'''
    insert ''array[i]'' into buckets[msbits(array[i], k)]
  '''for''' i = 0 '''to''' n - 1 '''do'''
    nextSort(buckets[i]);
  '''return''' the concatenation of buckets[0], ...., buckets[n-1]
 
Here ''array'' is the array to be sorted and ''n'' is the number of buckets to use. The function ''msbits(x,k)'' returns the ''k'' most significant bits of ''x'' (''floor(x/2^(size(x)-k))''); different functions can be used to translate the range of elements in ''array'' to ''n'' buckets, such as translating the letters A–Z to 0–25 or returning the first character (0–255) for sorting strings. The function ''nextSort'' is a sorting function; using ''bucketSort'' itself as ''nextSort'' produces a relative of [[radix sort]]; in particular, the case ''n = 2'' corresponds to [[quicksort]] (although potentially with poor pivot choices).
 
==Optimizations==
 
A common optimization is to put the unsorted elements of the buckets back in the original array ''first'', then run [[insertion sort]] over the complete array; because [[insertion sort|insertion sort's]] runtime is based on how far each element is from its final position, the number of comparisons remains relatively small, and the memory hierarchy is better exploited by storing the list contiguously in memory.<ref>Corwin, E. and Logar, A. "Sorting in linear time &mdash; variations on the bucket sort". ''Journal of Computing Sciences in Colleges'', 20, 1, pp.197&ndash;202. October 2004.</ref>
 
==Variants==
 
===Generic bucket sort===
The most common variant of bucket sort operates on a list of ''n'' numeric inputs between zero and some maximum value ''M'' and divides the value range into ''n'' buckets each of size ''M''/''n''. If each bucket is sorted using [[insertion sort]], the sort can be shown to run in expected linear time (where the average is taken over all possible inputs).<ref>[[Thomas H. Cormen]], [[Charles E. Leiserson]], [[Ronald L. Rivest]], and [[Clifford Stein]]. ''[[Introduction to Algorithms]]'', Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 8.4: Bucket sort, pp.174&ndash;177.</ref> However, the performance of this sort degrades with clustering; if many values occur close together, they will all fall into a single bucket and be sorted slowly.
 
===ProxmapSort===
{{Main|Proxmap sort}}
Similar to generic bucket sort as described above, '''ProxmapSort''' works by dividing an array of keys into subarrays via the use of a "map key" function that preserves a partial ordering on the keys; as each key is added to its subarray, insertion sort is used to keep that subarray sorted, resulting in the entire array being in sorted order when ProxmapSort completes. ProxmapSort differs from bucket sorts in its use of the map key to place the data approximately where it belongs in sorted order, producing a "proxmap" — a proximity mapping — of the keys.
 
===Histogram sort===
Another variant of bucket sort known as histogram sort or [[counting sort]] adds an initial pass that counts the number of elements that will fall into each bucket using a count array. Using this information, the array values can be arranged into a sequence of buckets in-place by a sequence of exchanges, leaving no space overhead for bucket storage.<ref>[http://www.nist.gov/dads/HTML/histogramSort.html NIST's Dictionary of Algorithms and Data Structures: histogram sort]</ref>
 
===Postman's sort===<!-- This section is linked from [[Radix sort]] -->
The '''Postman's sort''' is a variant of bucket sort that takes advantage of a hierarchical structure of elements, typically described by a set of attributes. This is the algorithm used by letter-sorting machines in [[post office]]s: mail is sorted first between domestic and international; then by state, province or territory; then by destination post office; then by routes, etc. Since keys are not compared against each other, sorting time is O(''cn''), where ''c'' depends on the size of the key and number of buckets. This is similar to a [[radix sort]] that works "top down," or "most significant digit first."<ref>http://www.rrsd.com/psort/cuj/cuj.htm</ref>
 
===Shuffle sort===<!-- This section is linked from [[J sort]] -->
The '''shuffle sort''' <ref>[http://groups.google.com/group/fido7.ru.algorithms/msg/26084cdb04008ab3 A revolutionary new sort from John Cohen Nov 26, 1997]</ref> is a variant of bucket sort that begins by removing the first 1/8 of the ''n'' items to be sorted, sorts them recursively, and puts them in an array. This creates ''n''/8 "buckets" to which the remaining 7/8 of the items are distributed. Each "bucket" is then sorted, and the "buckets" are concatenated into a sorted array.  Shuffle sort is used as a step in a [[J sort]].
 
==Comparison with other sorting algorithms==
 
Bucket sort can be seen as a generalization of [[counting sort]]; in fact, if each bucket has size 1 then bucket sort degenerates to counting sort. The variable bucket size of bucket sort allows it to use O(''n'') memory instead of O(''M'') memory, where ''M'' is the number of distinct values; in exchange, it gives up counting sort's O(''n'' + ''M'') worst-case behavior.
 
Bucket sort with two buckets is effectively a version of [[quicksort]] where the pivot value is always selected to be the middle value of the value range. While this choice is effective for uniformly distributed inputs, other means of choosing the pivot in quicksort such as randomly selected pivots make it more resistant to clustering in the input distribution.
 
The ''n''-way [[mergesort]] algorithm also begins by distributing the list into ''n'' sublists and sorting each one; however, the sublists created by mergesort have overlapping value ranges and so cannot be recombined by simple concatenation as in bucket sort. Instead, they must be interleaved by a merge algorithm. However, this added expense is counterbalanced by the simpler scatter phase and the ability to ensure that each sublist is the same size, providing a good worst-case time bound.
 
Top-down [[radix sort]] can be seen as a special case of bucket sort where both the range of values and the number of buckets is constrained to be a power of two. Consequently, each bucket's size is also a power of two, and the procedure can be applied recursively. This approach can accelerate the scatter phase, since we only need to examine a prefix of the bit representation of each element to determine its bucket.
 
==References==
<references />
 
* Paul E. Black [http://www.nist.gov/dads/HTML/postmansort.html "Postman's Sort"] from [[Dictionary of Algorithms and Data Structures]] at [[National Institute of Standards and Technology|NIST]].
* Robert Ramey [http://www.rrsd.com/software_development/postmans_sort/cuj/cuj.htm '"The Postman's Sort"] ''C Users Journal'' Aug. 1992
* [http://www.nist.gov/dads/HTML/bucketsort.html NIST's Dictionary of Algorithms and Data Structures: bucket sort]
 
==External links==
* [http://www.dcc.uchile.cl/~rbaeza/handbook/algs/4/423.sort.c.html Bucket Sort Code for Ansi C]
* [http://www1bpt.bridgeport.edu/~dichter/lilly/bucketsort.htm Variant of Bucket Sort with Demo]
 
{{sorting}}
 
[[Category:Sorting algorithms]]
[[Category:Stable sorts]]
[[Category:Articles with example pseudocode]]
 
[[fr:Tri comptage]]
[[uk:Сортування комі⊂⊇⊃∐рками]]

Revision as of 17:19, 28 January 2014

Template:Infobox Algorithm

Template:Expert-subject

File:Bucket sort 1.png
Elements are distributed among bins
File:Bucket sort 2.png
Then, elements are sorted within each bin

Bucket sort, or bin sort, is a sorting algorithm that works by partitioning an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a distribution sort, and is a cousin of radix sort in the most to least significant digit flavour. Bucket sort is a generalization of pigeonhole sort. Since bucket sort is not a comparison sort, the Ω(n log n) lower bound is inapplicable. The computational complexity estimates involve the number of buckets.

Bucket sort works as follows:

  1. Set up an array of initially empty "buckets".
  2. Scatter: Go over the original array, putting each object in its bucket.
  3. Sort each non-empty bucket.
  4. Gather: Visit the buckets in order and put all elements back into the original array.

Pseudocode

function bucketSort(array, n) is
  buckets ← new array of n empty lists
  for i = 0 to (length(array)-1) do
    insert array[i] into buckets[msbits(array[i], k)]
  for i = 0 to n - 1 do
    nextSort(buckets[i]);
  return the concatenation of buckets[0], ...., buckets[n-1]

Here array is the array to be sorted and n is the number of buckets to use. The function msbits(x,k) returns the k most significant bits of x (floor(x/2^(size(x)-k))); different functions can be used to translate the range of elements in array to n buckets, such as translating the letters A–Z to 0–25 or returning the first character (0–255) for sorting strings. The function nextSort is a sorting function; using bucketSort itself as nextSort produces a relative of radix sort; in particular, the case n = 2 corresponds to quicksort (although potentially with poor pivot choices).

Optimizations

A common optimization is to put the unsorted elements of the buckets back in the original array first, then run insertion sort over the complete array; because insertion sort's runtime is based on how far each element is from its final position, the number of comparisons remains relatively small, and the memory hierarchy is better exploited by storing the list contiguously in memory.[1]

Variants

Generic bucket sort

The most common variant of bucket sort operates on a list of n numeric inputs between zero and some maximum value M and divides the value range into n buckets each of size M/n. If each bucket is sorted using insertion sort, the sort can be shown to run in expected linear time (where the average is taken over all possible inputs).[2] However, the performance of this sort degrades with clustering; if many values occur close together, they will all fall into a single bucket and be sorted slowly.

ProxmapSort

Mining Engineer (Excluding Oil ) Truman from Alma, loves to spend time knotting, largest property developers in singapore developers in singapore and stamp collecting. Recently had a family visit to Urnes Stave Church. Similar to generic bucket sort as described above, ProxmapSort works by dividing an array of keys into subarrays via the use of a "map key" function that preserves a partial ordering on the keys; as each key is added to its subarray, insertion sort is used to keep that subarray sorted, resulting in the entire array being in sorted order when ProxmapSort completes. ProxmapSort differs from bucket sorts in its use of the map key to place the data approximately where it belongs in sorted order, producing a "proxmap" — a proximity mapping — of the keys.

Histogram sort

Another variant of bucket sort known as histogram sort or counting sort adds an initial pass that counts the number of elements that will fall into each bucket using a count array. Using this information, the array values can be arranged into a sequence of buckets in-place by a sequence of exchanges, leaving no space overhead for bucket storage.[3]

Postman's sort

The Postman's sort is a variant of bucket sort that takes advantage of a hierarchical structure of elements, typically described by a set of attributes. This is the algorithm used by letter-sorting machines in post offices: mail is sorted first between domestic and international; then by state, province or territory; then by destination post office; then by routes, etc. Since keys are not compared against each other, sorting time is O(cn), where c depends on the size of the key and number of buckets. This is similar to a radix sort that works "top down," or "most significant digit first."[4]

Shuffle sort

The shuffle sort [5] is a variant of bucket sort that begins by removing the first 1/8 of the n items to be sorted, sorts them recursively, and puts them in an array. This creates n/8 "buckets" to which the remaining 7/8 of the items are distributed. Each "bucket" is then sorted, and the "buckets" are concatenated into a sorted array. Shuffle sort is used as a step in a J sort.

Comparison with other sorting algorithms

Bucket sort can be seen as a generalization of counting sort; in fact, if each bucket has size 1 then bucket sort degenerates to counting sort. The variable bucket size of bucket sort allows it to use O(n) memory instead of O(M) memory, where M is the number of distinct values; in exchange, it gives up counting sort's O(n + M) worst-case behavior.

Bucket sort with two buckets is effectively a version of quicksort where the pivot value is always selected to be the middle value of the value range. While this choice is effective for uniformly distributed inputs, other means of choosing the pivot in quicksort such as randomly selected pivots make it more resistant to clustering in the input distribution.

The n-way mergesort algorithm also begins by distributing the list into n sublists and sorting each one; however, the sublists created by mergesort have overlapping value ranges and so cannot be recombined by simple concatenation as in bucket sort. Instead, they must be interleaved by a merge algorithm. However, this added expense is counterbalanced by the simpler scatter phase and the ability to ensure that each sublist is the same size, providing a good worst-case time bound.

Top-down radix sort can be seen as a special case of bucket sort where both the range of values and the number of buckets is constrained to be a power of two. Consequently, each bucket's size is also a power of two, and the procedure can be applied recursively. This approach can accelerate the scatter phase, since we only need to examine a prefix of the bit representation of each element to determine its bucket.

References

  1. Corwin, E. and Logar, A. "Sorting in linear time — variations on the bucket sort". Journal of Computing Sciences in Colleges, 20, 1, pp.197–202. October 2004.
  2. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 8.4: Bucket sort, pp.174–177.
  3. NIST's Dictionary of Algorithms and Data Structures: histogram sort
  4. http://www.rrsd.com/psort/cuj/cuj.htm
  5. A revolutionary new sort from John Cohen Nov 26, 1997

External links

Template:Sorting

fr:Tri comptage uk:Сортування комі⊂⊇⊃∐рками