public void selectionSort() throws Exception
{ queue theQ=new queue(4);
int a=0;
for (int =0; <used-1; ++)
{
int minIndex = findMin();
swap(, minIndex);
theQ.append(a++);
counterA=theQ.serve()+1;
}
System.out.println(counterD+" "+counterB+" "+counterC+" "+counterA);
}
private int findMin(int )
{ queue theQ1=new queue(4);
int b=0;
int d=0;
int posmin=;
try{ for (int i=posmin+1; i<used; i++)
if(theList[i]<theList[posmin])
{ posmin=i;
theQ1.append(b++);
counterB=theQ1.serve()+1;
}
theQ1.append(d++);
counterD=theQ1.serve()+1;
}
catch(Exception e){};
return posmin;
}
public void insertionSort() throws Exception
{
queue theQ=new queue(4);
theQ.reset();
int c1=0;
int b1=0;
int d1=0;
for(int =1;<used;++)
{
int temp=theList[];
int i=-1;
while(i>=0&&theList[i]>temp)
{
theList[i+1]=theList[i];
theQ.append(b1++);
counterB=theQ.serve()+1;
i--;
}
theList[i]=temp;
theQ.append(c1++);
counterC=theQ.serve()+1;
}
theQ.append(d1++);
counterD=theQ.serve()+1;
System.out.println(counterD+" "+counterB+" "+counterC+" "+counterA);
}
我想知道这两种sort 有多少Iteration | Comparisons | Copies | Swaps高手给我看看吧
{ queue theQ=new queue(4);
int a=0;
for (int =0; <used-1; ++)
{
int minIndex = findMin();
swap(, minIndex);
theQ.append(a++);
counterA=theQ.serve()+1;
}
System.out.println(counterD+" "+counterB+" "+counterC+" "+counterA);
}
private int findMin(int )
{ queue theQ1=new queue(4);
int b=0;
int d=0;
int posmin=;
try{ for (int i=posmin+1; i<used; i++)
if(theList[i]<theList[posmin])
{ posmin=i;
theQ1.append(b++);
counterB=theQ1.serve()+1;
}
theQ1.append(d++);
counterD=theQ1.serve()+1;
}
catch(Exception e){};
return posmin;
}
public void insertionSort() throws Exception
{
queue theQ=new queue(4);
theQ.reset();
int c1=0;
int b1=0;
int d1=0;
for(int =1;<used;++)
{
int temp=theList[];
int i=-1;
while(i>=0&&theList[i]>temp)
{
theList[i+1]=theList[i];
theQ.append(b1++);
counterB=theQ.serve()+1;
i--;
}
theList[i]=temp;
theQ.append(c1++);
counterC=theQ.serve()+1;
}
theQ.append(d1++);
counterD=theQ.serve()+1;
System.out.println(counterD+" "+counterB+" "+counterC+" "+counterA);
}
我想知道这两种sort 有多少Iteration | Comparisons | Copies | Swaps高手给我看看吧
{ queue theQ=new queue(4);
int a=0;
for (int =0; <used-1; ++) // used 这个变量在哪定义的?