`

java Data Structural / shujujiegou / paixusuanfa / paixu

    博客分类:
  • Java
阅读更多

 

http://panthema.net/2013/sound-of-sorting/     

The Sound of Sorting - "Audibilization" and Visualization of Sorting Algorithms TalkBox Gravatar Timo: I don't see much point in the input types, you can check out the code and try these yourself. One can add many different types of inputs. There is no release schedule. Releases are quite a hassle to make, but once enough additional algorithms are added in the git repo, I'll make new binaries. Gravatar mgutt: Could you add ascending/descending cubic and quintic input types? When do you plan to push to a new downloadable executable? Just wondering. Gravatar Timo: @Dan: thanks for the bug report. It's fixed in git now, the number of radix rounds needed was too low for n=4^k. Gravatar Dan: Radix sort LSD gives incorrect results every time with array size 12 and shuffled cubic or quintic as source on linux version. Gravatar Timo: Yes, well, I don't have Windows 8.1. Gravatar mgutt: I found something about high-resolution timers for Windows 8.1 and later. Would be great to have the < 1 ms resolution. Gravatar Timo: @mgutt: that sounds like a very good idea. I'll replace the "Random" button with Shuffle/Reset in the next version. @Page: Execution time analysis of sorting algorithms is really difficult. It depends on many parameters like hardware, input and implementation. It is really outside the scope of SoS, which is primarily an educational tool. Gravatar Page: Have you done any kind of comparison statistics of total computing time vs array accesses/comparisons? Those would be pretty cool. Gravatar mgutt: It would be nice if the "Reset" button simply reverted the array to its presorted state, not mix the elements. That way, it is possible to see different sorting algorithms being performed on the exact same array. To mix the array, you could add a "Shuffle" button. Gravatar mgutt: Please add Timsort, Stooge sort, and slow sort to the demo program. This program is so amazing to me. Gravatar Timo: TimSort is already implemented on git. Wouldn't KraaySort violate a patent? I can't find any implementation. Gravatar mr.k.s.a: hi https://github.com/gfx/cpp-TimSort Gravatar kone: implement kraaysort link1 link2 link3 link4 Gravatar Sampo Syreeni: The sound in that andrut video has clearly been done by modulating the cutoff point of an analog-like filter, over a toothy waveform. Maybe a fixed high saw waveform or something like that. I might be wrong, but the filter might also be the rarest one in analog synthesis: the band reject one. Gravatar Alessandro: That would be amazing if I were able to manually specify the input: I would definitely use this to try making a song!!! :D Gravatar Timo: Upon your requests: added TimSort, Slow Sort and Stooge Sort (see github). Videos about them are also on Youtube now. Cheers, Timo Gravatar quchen: Slowsort is missing! It's a highly entertaining variant of mergesort, described in this paper: http://www.cse.ohio-state.edu/~yusu/courses/780/pessimal.pdf Gravatar ahmet: yes yes timsort pls Gravatar Shintaro: Hi! Here some links to an other project we did in 2010. http://sourceforge.net/p/algorhythmics/code/288/tree/algorhythmicSorting/ https://vimeo.com/42353230 Gravatar Keith: Would love to see Timsort too: http://en.wikipedia.org/wiki/Timsort Posted on 2013-05-22, last updated 2013-11-26 by Timo Bingmann at Permlink.

sound-of-sorting-0.6-win32.zip 

http://dl.iteye.com/topics/download/a4449a92-af61-32bb-bab4-76c9cfeaa49e

程序猿的世界我们不懂 15种排序算法演示

http://v.gamersky.com/201404/350555.shtml

1、选择排序

2、插入排序

3、快速排序

4、归并排序

5、堆排序

6、基数排序

7、是C++标准库自带的一个排序方法,实质上就是快速排序

8、同样是C++的一个排序法

9、希尔排序

10、冒泡排序

11、双向冒泡排序,是10的变种

12、地精排序

13、双调排序

14、严格来说它不是一种排序法,它只是把元素随意打乱看是否有序,若否则再次打乱,理论上时间复杂度是无限的,因此我觉得它不能算是排序法,没有第15,总共只有14种排序法

15、最后一个是穷举法吗,就是把所有可能的排列都列举一遍,找出与条件相符的。 

 

 

http://jiangzhengjun.iteye.com/blog/pdf

http://jiangzhengjun.iteye.com/blog/547734

http://jiangzhengjun.iteye.com/blog/547735

 

排序算法分析与实现
查看目录

 

 

申明:  排序算法思想来自互联网,代码自己实现,仅供参考。

  • 插入排序

直接插入排序、希尔排序

  • 选择排序

简单选择排序、堆排序

  • 交换排序

冒泡排序、快速排序

  • 归并排序
  • 基数排序

排序基类

 

时间复杂度与空间复杂度对比表

 

 

http://shenyu.iteye.com

 

枚举算法

有N(N>=3)位同学去照相,每次照三个同学,共可照出多少张不同的照片?每张照片都是谁?

 

package com.lindows.test;

public class CountNum {

		public static void main(String[] args)
		{
			int total =4;		
			for(int i =0;i<= total-3;i++)
			{
				for(int j =i+1;j<= total-2;j++)
				{
					for(int k =j+1;k<= total-1;k++)
					{
						System.out.println(print(i)+":"+print(j)+":"+print(k));
					}
				}
			}
		}
		
		public static char print(int num)
		{		
			return (char)((int)'A' + num);
		}



}

asdfsfa

?

冒泡法排序示例
文件:Sort.java  
内容:  
public class Sort
{
public static void main (String[] args) {
??System.out.print("以下有10个数: 5,2,3,6,8,7,1,0,9,4\n");
??int[] num = new int[]{5,2,3,6,8,7,1,0,9,4};
??//boolean isChange = false;
??for(int i=0;i<9;i++)
??{
?? //isChange = false;
?? for(int j=0;j<9;j++)
?? {
????if(num[j]>num[j+1])
????{
???? int temp = num[j];
???? num[j] = num[j+1];
???? num[j+1] = temp;
???? //isChange = true;???? 
????}
?? }
?? //System.out.print(num[i-1]);
??}
??System.out.print("\n冒泡排序后为: ");
??for(int k=0;k<10;k++)
?? System.out.print(num[k]+ ",");
}??
}
结果:
以下有10个数: 5,2,3,6,8,7,1,0,9,4
冒泡排序后为: 0,1,2,3,4,5,6,7,8,9,

 

 

 

冒泡,选择,插入排序 java版

http://hpjianhua.iteye.com/blog/846021

公共代码交换两个数的方法: 
Java代码 
  1. /**  
  2.  * 交换两个数的方法  
  3.  * @param data 交换的数组  
  4.  * @param i 位置i的数组下标  
  5.  * @param j 位置j的数组下标  
  6.  */   
  7. public   static   void  swap( int [] data,  int  i, int  j){  
  8.     //  当只有是不同一位置的两个数才进行交换   
  9.     if (i!=j){  
  10.          int  temp =  0 ;  
  11.          temp = data[j];  
  12.          data[j] = data[i];  
  13.          data[i] = temp;  
  14.     }  
  15. }  

1.插入排序: 
思想:每步将一个待排序的对象,按其关键码大小,插入到前面已经排好序的一组对象的适当位置上,直到对象全部插入为止。 

代码实现: 
Java代码 
  1. /**  
  2.  * 插入排序算法  
  3.  * 每进行一次排序,就需要将要比较的数与有序的序列进行一一对比  
  4.  * @param data  
  5.  * @param n  
  6.  */   
  7. public   static   void  insertion( int [] data,  int  n){  
  8.     for ( int  i =  0  ; i < data.length;i++){  
  9.         for ( int  j =  0  ; j<i;j++){  
  10.             if (data[i]<data[j]){  
  11.                 swap(data,i,j);  
  12.             }  
  13.         }  
  14.         System.out.println("第" +i+ "趟:" +Arrays.toString(data));  
  15.     }  
  16. }  

2.选择排序: 
思路简单:每经过一趟比较就找出一个最小值,与待排序列最前面的位置互换即可。 
——首先,在n个记录中选择最小者放到r[1]位置;然后,从剩余的n-1个记录中选择最小者放到r[2]位置;…如此进行下去,直到全部有序为止。 
优点:实现简单 
缺点:每趟只能确定一个元素,表长为n时需要n-1趟 
前提:顺序存储结构 


Java代码 
  1. /**  
  2.  * 选择排序算法  
  3.  * 每经过一趟比较就找出一个最小值,与待排序列最前面的位置互换即可  
  4.  * @param data  
  5.  * @param n  
  6.  */   
  7. public   static   void  select( int [] data,  int  n){  
  8.     for ( int  i =  0  ; i < data.length; i++){  
  9.         int  min = i;  
  10.         for  ( int  j = i+ 1 ; j<data.length; j++){  
  11.             if (data[j]<data[min]){  
  12.                 min = j;  
  13.             }  
  14.         }  
  15.         if (i!=min){  
  16.             swap(data,min,i);  
  17.         }  
  18.         System.out.println("第" +i+ "趟:" +Arrays.toString(data));  
  19.     }  
  20. }  

冒泡排序: 
基本思路:每趟不断将记录两两比较,并按“前小后大”(或“前大后小”)规则交换。(逆序则交换) 
优点:每趟结束时,不仅能挤出一个最大值到最后面位置,还能同时部分理顺其他元素;一旦下趟没有交换发生,还可以提前结束排序。 
前提:顺序存储结构 
Java代码 
  1. /**  
  2.  * 冒泡排序算法  
  3.  * 每次都是进行相邻两个数的比较,每比较一次,比较的个数就变少一个  
  4.  * @param data  
  5.  * @param n  
  6.  */   
  7. public   static   void  bubble( int [] data,  int  n){  
  8.     for ( int  i =  1 ; i <=data.length; i++){  
  9.         for ( int  j =  0 ; j<(data.length-i);j++){  
  10.             if (data[j]>data[j+ 1 ]){  
  11.                 swap(data,j,j+1 );  
  12.             }  
  13.         }  
  14.         System.out.println("第" +i+ "趟:" +Arrays.toString(data));  
  15.     }  
  16. }  

 

http://yiyickf.iteye.com/blog/1047010

http://www.cppblog.com/guogangj/archive/2009/11/13/100876.html

排序算法java版:冒泡排序、简单选择排序、直接插入排序、折半插入排序、希尔排序、堆排序、归并排序、快速排序

先推荐一篇关于排序算法的文章:http://www.cppblog.com/guogangj/archive/2009/11/13/100876.html

本文思路部分来源于上篇文章,但测得的结果似乎不大相同,不知是因为java的缘故还是因为我算法的缘故,欢迎拍砖。

复习排序,顺便比下各种算法的速度,榜单如下:

1、冒泡排序

2、简单选择排序

3、直接插入排序

4、折半插入排序

5、希尔排序

6、堆排序

7、归并排序

8、快速排序

当然这是慢速排行,哈哈~~

 

 

直接上图:单位毫秒

 

数量

冒泡排序

简单选择排序

直接插入排序

折半插入排序

希尔排序

堆排序

归并排序

快速排序

10000 个

1578

1250

672

250

0

15

16

0

15000 个

3453

2765

1563

531

16

15

16

0

20000 个

6140

4547

2453

828

16

16

15

16

25000 个

10079

7171

3969

1313

31

16

15

16

30000 个

14641

10313

5578

1906

31

31

16

31

35000 个

20141

14328

7890

2563

31

31

32

15

40000 个

25766

18359

10094

3422

47

31

31

32

45000 个

32469

24063

13062

4359

47

47

31

47

 

 

 

end

分享到:
评论

相关推荐

    ansys面与面接触分析实例.pdf

    在 ANSYS 中,可以通过选择 Material Props/Material Models/Structural/Liner/Elastic/Isotropic 来定义材料属性,例如摩擦系数等。 四、温度加载 温度加载是面与面接触分析的重要步骤。在 ANSYS 中,可以通过...

    CNV_SV-visualisation:可视化拷贝数变更和结构变体

    命令行使用示例: Rscript SVbezierPlot.R --bedpe example_data/structural/example-manta-pass.bedpe --output example_data/structural/SVbezierPlot这将输出类似曲线的图,表示生成的文件中的结构变体。...

    structural materials /electronic ceramics

    ### 结构材料与电子陶瓷 #### 标题与描述中的知识点概述 结构材料与电子陶瓷是材料科学领域中两个重要的分支。这些材料被广泛应用于工业、航空航天、电子设备等多个行业中,因为它们具备独特的物理和化学特性。...

    data_all.rar_DATA ALL_structural health_模态_模态识别_结构健康

    在工程领域,尤其是土木、航空航天和机械工程中,结构健康监测(Structural Health Monitoring, SHM)是一项至关重要的技术,它能实时评估和预测结构的安全性。本资料包"**data_all.rar**"包含了与结构健康和模态...

    Programming Finite Elements in Java

    Problems and exercises are provided for each chapter, with Java™ source code and problem data sets available from the book’s webpage at springer.com/978-1-84882-971-8. Graduate students using the ...

    薄板圆孔的ANSYS分析.pdf

    接着,双击“structural/linear/elastic/isotropic”选项,弹出“linear isotropic material properties for material number 1”对话框,输入弹性模量E=2e11和泊松比ν=0.3,单击“OK”按钮,执行“exit”命令。...

    airframe structural design 2

    airframe structural design 的第二部分,两个都下了才能解压

    结构相似性指数(Structural Similarity Index)

    利用MATLAB进行结构相似性指数(Structural Similarity Index)计算

    Structural Priors in Deep Neural Networks.pdf

    Structural Priors in Deep Neural Networks Yani Andrew Ioannou Department of Engineering University of Cambridge This dissertation is submitted for the degree of Doctor of Philosophy

    动力节点【Java八股文】.pdf

    "动力节点【Java八股文】.pdf" 本资源摘要信息涵盖了 Java 编程语言的基本概念、面向对象编程、JavaSE、数据库基础知识、Java Web 开发、框架和工具等多方面的知识点。 Java 基础知识 1. 面向对象编程(OOP):...

    Java Interview Guide.epub

    This book will teach you object-oriented concepts, data structures, design patterns, and algorithms in interview-sized chunks with over 150 corresponding questions. I promise that if you read it ...

    Structural Equation Modeling

    结构方程建模(Structural Equation Modeling,简称SEM)是一种复杂的统计建模技术,它结合了因子分析和回归分析的技术,用来检验模型中包含的因果关系。SEM常用于社会科学、环境科学、心理学、经济学等领域的研究,...

    Structural Closures (ch600-1) (2005)

    ### 结构封闭(Structural Closures) #### 引言与背景 《结构封闭》(Structural Closures ch600-1 2005)是美国海军技术手册中的一个章节,更新自2002年12月31日的版本。此章节主要涵盖了船舶上非弹道性水密和气密门...

    The Plastic Methods of Structural Analysis

    The Plastic Methods of Structural Analysis B G Neal 结构分析的塑性方法

    Learning Functional Data Structures and Algorithms

    Find out how the internal algorithms are redesigned to exploit structural sharing, so that the persistent data structures perform well, avoiding needless copying. Get to know functional features like ...

    Structural mechanics2020R2.pdf

    《ANSYS Structural Mechanics 2020R2:新特性详解》 ANSYS Structural Mechanics 2020R2版本的发布带来了许多重要的更新和增强,涵盖了从结构计算的前处理到后处理,以及计算能力的提升等多个方面。这篇解析将深入...

    Structural Equation Modeling Example

    结构方程模型(Structural Equation Modeling, SEM)是一种多变量统计技术,它结合了路径分析和验证性因子分析,用于估计复杂关系网络中的变量间的因果效应。本案例通过WinAMOS软件对Wheaton的社会疏离研究进行SEM...

Global site tag (gtag.js) - Google Analytics