Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Bucket Sort Question

  Asked By: Hisham    Date: Jul 01    Category: Java    Views: 995
  

i have to write a method called bucketSort that accepts an array and
sorts it. Does anyone know how to do this.

Also

if i have something like

for
{
for
{
if
{
for
{
if
(If this if statement is true how i can make it
return to the original for statement at the top and skip everything
else.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Tyrone Sanchez     Answered On: Jul 01

To sort  an array, look into the Comparator interface.

Second question, put a label on the for loop that you
want to continue and name the label in your continue.

Example :

outer :
for
{
for
{
if
{
for
{
if ( true  )
continue outer;
...

 
Answer #2    Answered By: Jonathan Brown     Answered On: Jul 01

call a method  in the outer for loop and put the rest of the loops in
that method.
then you just return from the new method if the inner if statement
evaluates true
so:
for
{
dooloop(...)

void dooloop(...)
{

for
{
if
{
for
{
if
return

}

 
Answer #3    Answered By: Husani Chalthoum     Answered On: Jul 01

This sounds like homework. Hence, it should be in your notes and/or
book. Did you try Google? Incidentally, this sort  is also called  a
radix sort.

 
Didn't find what you were looking for? Find more on Bucket Sort Question Or get search suggestion and latest updates.




Tagged: