I'm writing a program to compare the effiecency between heapsort and bubblesort. We were givin the code for both of the sorts and have to use them. The only problem is the code contains Object arrays and I'm not sure how to put integers (we have to make the arrays for testing) into the Object array coding. I created the integer arrays by using a simple for loop with a random number generator which works fine. Any help to tell me how to put ints into Object arrays would be appreciated. Here is the heapsort algorithm we were given that we have to use:
Here is how I am creating my random integer array:
Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Joined: Sep 25, 2004
Yeah, just figured that out, hehe. But now the algorithm he gave us isnt doin much
here's the code he gave us. I'm sure i'm doing something wrong opposed to his code being wrong.
Joined: Jul 30, 2003
I would suggest starting with adding some debug print statements so you can compare what you think the program should be doing at several points compared to what the program really is doing at those points. For example, where the code is assigning a value, for example:
You could add a print statement to see what really is being assigned to temp:
[ February 09, 2005: Message edited by: Jeff Bosch ]