![]() |
|
#1
|
|||
|
|||
Help with a bucket sort please.Hi I am trying to sort my array with a bucket sort. Several different kind of sorts for arrays are listed in my book but not bucket sorts. I get the concept on 97 goes in 7 and 3 goes in three when sorting by ones and then in 9 and 0 when sorting by ones but I don[t have any information on how to code a bucket sort. Please help me.
|
|
#2
|
|||
|
|||
Sorry forgot to add the code I already written on earlier post.This is the code for the array that I am trying to sort with a bucket sort.
CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
|
Try a google search for "bucket sort code". Only 416,000 hits and at least 6 on the first page look likely.
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#4
|
|||
|
|||
I did the search on many search engines but I am still confused.I keep trying different ways to get this bucket sort but I don't have much to go on because their is nothing on bucket sorts in my book. I have used search engines to try to find out about them. They show me some code about them but nothing on how they work in arrays. I am just getting more confused.
CPP / C++ / C Code:
Last edited by LuciWiz : 16-Apr-2005 at 02:08.
Reason: The way to do it is [c] code [/c]
|
|
#5
|
|||
|
|||
|
Quote:
The code you posted makes no sense to me. The main program doesn't create an array of random numbers, it doesn't call the sort routine, and the sort routine won't compile (not even close). I will tell you that the expression "bucket sort" has been used in lots of ways through the ages, so lots of search engine links will have nothing to do with what I think you are trying to tell us. I know it's confusing and frustrating. Maybe you can go back through your course notes and ask the instructor for clarification of things you don't understand. However, even after having said all that: your description makes me think you should look at This Link since the description there seems to be somewhat consistent with the way you tried to state the problem (even using the example numbers 97 and 3). Maybe you can look there and see if you can follow the instructions. Make a real effort to put it together, and ask specific questions if you get stuck. Regards, Dave |
|
#6
|
|||
|
|||
Ok I think I fixed part of it.Ok I restarted from the beginnig I think that I now have an array that is being filled with random numbers. Now I am working on the bucket sort.
CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
Ok this is what I have for my bucket sort.I tried to write a bucket code function and then call it into the generated array but I keep getting this error : missing function header (old-style formal list?)
this is my code so far. CPP / C++ / C Code:
|
|
#8
|
||||
|
||||
|
Quote:
Get rid of the .h on #include <iostream.h> Search this site for additional info... use iostream.h as a search parameter and see what turns up. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#9
|
||||
|
||||
|
Quote:
You have a misplaced semicolon: CPP / C++ / C Code:
Also, what is size here: CPP / C++ / C Code:
I hope it's a constant. Best regards, Lucain __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein Last edited by LuciWiz : 18-Apr-2005 at 02:39.
|
|
#10
|
||||
|
||||
|
I just noticed you pass a as a int to the function, but then you use it as an array:
CPP / C++ / C Code:
Also, you can't use an array without an indexer in C/C++ like this: CPP / C++ / C Code:
Regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Merge sort on a linked list | Temujin_12 | C++ Forum | 1 | 06-Mar-2008 21:33 |
| bucket sort problem | ap6118 | C++ Forum | 3 | 15-Apr-2005 19:02 |
| [GIM] gim.h | dsmith | C Programming Language | 0 | 18-Jan-2005 09:48 |
| insert sort | saphir55 | C Programming Language | 4 | 06-Dec-2004 15:00 |
| help with Sort arrays/Size | justachessgame | C Programming Language | 1 | 13-Nov-2004 00:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The