• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need some help with JAVA

Xylitol

Diamond Member
I have to sort an array using insertion sort (where you take the # after the number you are checking and switch them if that number is larger)
I also have to count the # of operations that the sort goes through (ie - for loop = 3)

My code right now is this:
public static int selectionSort(int[] list)
{
int count = 0;
for (int i=0; i<list.length-1; i++)
{
count +=3;
if (list > list[i+1])
{
int temp = list;
list = list [i+1];
list [i+1] = temp;
count +=3;
}
}
return count;
}
 
Originally posted by: QurazyQuisp
Originally posted by: Xylitol

I refuse because programming is getting muffled up with games/software

There are actually quite a few decent people... one of my questions was answered within minutes...

If this was C++, I could tell you how, it looks like java is quite a bit like c++ but I'm not sure exactly how it works.

alright I took your advice
 
Back
Top