Skip to main content

Posts

Showing posts with the label bucket sort

Bucket Sort

The following uses the divide-and-conquer method of resolution, by dividing the problem into smaller arrays, sorting each smaller array, then reinserting the subarrays back into the original array.  This is not a pure solution, in that it uses the .NET List, rather than a linked list struct. using System; using System.Collections; using System.Collections.Generic; namespace Algorithms {     class BucketSort     {         public int[] Sort()         {                //creates arbitrary array             int[] arrayToSort = { 11, 7, 22, 2, 33, 3, 17, 44, 4, 55, 5, 66, 6, 1, 77 };             //create bucket using hash, x/10             List<int>[] bucketList = CreateHashedArray(arrayToSort, 10);             //sort the bucket list back into the or...