package com.victor.sort.seeds;
import java.util.ArrayList;
/**
* 倒序
* @author 黑妹妹牙膏
*
*/
public class Reversed extends Seeds {
@Override
protected ArrayList<Integer> doGenerate(int size) {
ArrayList<Integer> seedsList = new ArrayList<Integer>();
java.util.Random rd = new java.util.Random();
for(int i=0;i<getSize();i++)
{
int nextValue = rd.nextInt(3)+3*(getSize()-i);
seedsList.add(nextValue);
}
return seedsList;
}
@Override
public String getDescriptions() {
return "Sorting an array that is initially in reverse sorted order is " +
"an interesting case because it is common in practice and it brings " +
"out worse-case behavior for insertion sort, bubble sort, and shell sort.";
}
@Override
public String getName() {
return "Reversed Initial Order";
}
public static void main(String[] args)
{
Seeds rd = new Reversed();
rd.setSize(20);
rd.generate();
rd.print();
}
}