首页 > 代码库 > 倒序的种子数据结构 - Reversed
倒序的种子数据结构 - Reversed
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(); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。