• 100% Satisfaction Guarantee
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 755
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
44076068
Ingo U is online now

# C++ QuestionBucket sort program.This file must contain

### Resolved Question:

C++ Question

Bucket sort program.

This file must contain the following:
Entire C++ directory structure tree
A fully tested and appropriately commented program

(Bucket Sort) A bucket sort begins with a one-dimensional array of positive integers to be sorted and a two-dimensional array of integers with rows subscripted from 0 to 9 and columns subscripted from 0 to n - 1, where n is the number of values in the array to be sorted. Each row of the two-dimensional array is referred to as a bucket. Write a method bucketSort that takes an integer array as an argument and performs as follows:

Place each value of the one-dimensional array into a row of the 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."

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.

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 tens digit) and 97 is placed in row 9. After the gathering pass, the order of the values in the one-dimensional array is 100, 3 and 97. On the third pass, 100 is placed in row 1, 3 is placed in row 0 and 97 is placed in row 0 (after the 3). After the last gathering pass, the original array is now in sorted order.

Note that the two-dimensional array of buckets is ten 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 the data back to the original array on each pass. Another possibility is to create a second two-dimensional bucket array and repeatedly swap the data between the two bucket arrays.

The BucketSort function should be implemented in a separate .cpp file from the main program with the function prototype specified in a .h file with the same name.

The main program should contin, in addition to the main program, and initialization function that will take an array and the array length as input parameters and initialize it to contain randomly generated numbers between 0 and 10,000.

The main program should:

a) declare and initialize an array of 16 integers (using the initialization function described above)
b) print out the contents of the array
c) call the sort function
d) print out the contents of the sorted array

I really need good comments to understand what's going on. Thank you!
Submitted: 4 years ago.
Category: Homework
Expert:  Josie-Mod replied 4 years ago.
Hi, I'm a Moderator for this topic. I've been working hard to find a professional to assist you right away, but sometimes finding the right professional can take a little longer than expected.

I wonder whether you're ok with continuing to wait for an answer. If you are, please let me know and I will continue my search. If not, please let me know and I will cancel this question for you. Thank you!
Customer: replied 4 years ago.
I would like to continue the search.
Expert:  Josie-Mod replied 4 years ago.
Thank you for your continued patience. We will continue the search for a professional for you.
Expert:  Josie-Mod replied 4 years ago.
Thank you for your patience, your business is very important to us, we are waiting on the professional with the right expertise to come online. Please let us know if you would like us to continue searching for a professional or if you would like us to close your question. Thank you for your understanding!
Customer: replied 4 years ago.
Should I offer more money? I can. please let me know.
Expert:  Josie-Mod replied 4 years ago.
Customer: replied 4 years ago.
I've got all 3 files; the main.cpp, another cpp and a header file (well commented) and I've uploaded to wikisend so all I'm needing the expert to do at this point is fix my code because I've got errors at run/compile time. The link can be found at

I really need the help. Thank you!
Customer: replied 4 years ago.
I really need your help on another posted problem where I've got all three files down (and really close to the right answer - I know it) but am getting some errors at compile/runtime. It's worth the price to me just to have you check it out and let me know what to fix - I've commented it pretty well:

The 2 cpp files and 1 header file are here:

Can you take the question? I really liked what you taught me on the last one and I need it since it's due tomorrow. I may be able to fix it, but I really need someone with your skills b/c I am not confident I can. Thanks!
Expert:  Ingo U replied 4 years ago.
Hi,
I took a look at your files; it looks like you're using Windows - how about the compiler? Visual Studio perhaps? If so, can you zip up the whole project folder and upload it? For one, you have an #include "BucketSort.h" but that files is not there.
Thanks,
Ingo U
Customer: replied 4 years ago.

Thank you so much! Yes, I'm using VS 2010 professional. I thought the header file was up there. I apologize. I've put a 7 zip of the entire project at:

Thank you!

Expert:  Ingo U replied 4 years ago.
OK, got it - but is it possible the files somehow got corrupted by 7zip? I'm getting 77 compile errors, much of it due to what looks like file corruption - for example, comments that should start with /* just start with *.
Can you try to just put everything in a windows zip file (compressed folder) to see if that changes anything at my end?
Thanks!
Customer: replied 4 years ago.

OK. I was getting errors as well with compiler. Not that many though, here's the windows zip file:

Thanks again.

Customer: replied 4 years ago.
This is a better version of the file - down to one error and one warning:

Expert:  Ingo U replied 4 years ago.

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 755
Experience: Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL