hey guys. I'm new to this forum. I'm taking computer science at my high school this year, and was wondering if you could help me out with my shell sort program im writing. Here's the method that I wrote...
If it helps, heres the output that I get.
Inputed Order:
1
2
3
4
5
6
7
8
9
10
Descending Order:
9
8
6
7
10
1
2
3
4
5
Thanks alot!
Code:
static void sort(int [] list, int size)
{
for(int gap = size / 2; gap > 0; gap /= 2)
{
for(int c = 0; c < gap; c++)
{
if(list[c] < list[c+gap])
{
int temp = list[c];
list[c] = list[c+gap];
list[c+gap] = temp;
}
}
}
}
If it helps, heres the output that I get.
Inputed Order:
1
2
3
4
5
6
7
8
9
10
Descending Order:
9
8
6
7
10
1
2
3
4
5
Thanks alot!
Comment