I am asked to write my own version of Bucket Sort for Sorting an array of objects. My plan is to write a simple Entry class and another class with a main method and try to manipulate an array of lists. This is what I have so far, I just need some help putting it all together because I'm not very experienced with coding but I know what I am supposed to do. What would it look like sorting just an array of integers, that way I might have better understanding.
My Entry Class (Class Node):
public class Node {
protected int element;
protected Node next;
public Node()
{
element = 0;
next = null;
}
public Node getNext(Node n)
{
return next;
}
public void setNext(Node n)
{
n = next;
}
public void setElement(int e)
{
e = element;
}
public int getElement()
{
return element;
}
public void insert(int e)
{
e = element;
}
}
My Bucket Sort Class:
public class BucketSort extends Node {
public void remove(int[] x)
{
x = null;
}
public static void bucketSort(int[] a)
{
int[] array = a;
Node[] buckets = new Node[array.length];
for (int i=0; i<array.length; i++)
{
buckets[i] = null;
}
for (int i=0; i<array.length; i++)
{
array.remove(array[i]);
buckets[i].insert(array[i]);
}
}
}
I do get an error at array.remove(array[i]); as well.