![]() |
|
#1
|
|||
|
|||
Single-subscripted array into a row of bucket arrayThis is the problem from our book...so i hope you can help me..Im a new member of this forum..tnx anyway...
a.Place each value of the single-subscripted array into a row of bucket array based on the value's ones digit. For example, 97 is placed in row 7, 3 is placed in row 3 and 100 is placed in row 0. This is called a "distribution pass." b) Loop through the bucket array row by row, and copy the values back to the original array. This is called a "gathering pass." The new order of the preceding values in the single-subscripted array is 100, 3 and 97. c) Repeat this process for each subsequent digit position (tens, hundreds, thousands, etc.). On the second pass, 100 is placed in row 0, 3 is placed in row 0 (because 3 has no ten digit) and 97 is placed in row 9. After the gathering pass, the order of values in the single-subscripted array is 100, 3 and 97. On the third pass 100 is placed in row 1, 3 is placed in row zero and 97 is placed in row zero (after the 3). After the last gathering pass, the original array is now in sorted order. Note that the double-subscripted array of buckets is 10 times the size of the integer array being sorted. This sorting technique provides better performance than a bubble sort, but requires much more memory. The bubble sort requires space for only one additional element of data. This is an example of the space-time trade-off: The bucket sort uses more memory than the bubble sort, but performs better. This version of the bucket sort requires copying all data back to the original array on each pass. Another possibility is to create a second double-subscripted array and repeatedly swap the data between the two bucket arrays. |
|||
|
#2
|
|||
|
|||
Re: help me..i need it asap..Why don't you start us off with a program:
- declaring the two arrays - and maybe an attempt to do the 'first pass' processing of part 'a.'. Then build from there. |
|
#3
|
|||
|
|||
Re: help me..i need it asap..I have coded a simple bucket sort.
Here it is. CPP / C++ / C Code:
Hope this helps. |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Connect MS SQL Server 2005 to MFC Dialog application | -girl- | MS Visual C++ / MFC Forum | 22 | 20-Aug-2008 15:58 |
| Calculator Java Class | sneakerhead724 | Java Forum | 12 | 26-Mar-2008 20:16 |
| I need help with three C++ assignments asap please | silverneon | C++ Forum | 2 | 26-Apr-2007 04:40 |
| Array 1 dimensional help please asap | lion123 | C Programming Language | 10 | 18-Feb-2005 21:53 |
| Need Help ASAP | yeshwanth | C++ Forum | 0 | 04-Oct-2004 01:22 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The