Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a_Selection 选择排序算法 #1

Open
BleethNie opened this issue Mar 30, 2017 · 0 comments
Open

a_Selection 选择排序算法 #1

BleethNie opened this issue Mar 30, 2017 · 0 comments

Comments

@BleethNie
Copy link

  1. 插入排序算法

  2. public static int[] Selection_Sort(int[] a) {
  3.     int N = a.length;
    
  4.     int min = 0;
    
  5.     for (int i = 0; i < N - 1; i++) {
    
  6.     	min = i;
    
  7.         for (int j = i + 1; j < N; j++) {
    
  8.             if (a[min] > a[j]) {
    
  9.                 min = j;
    
  10.             }
    
  11.         }
    
  12.         std.swap(a, i, min);
    
  13.     }
    
  14.     return a;
    
  15. }
    
  16. 该方法第9行缺少min=i; 最小值回跳操作
@BleethNie BleethNie reopened this Mar 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant