Skip to content

a_Selection 选择排序算法 #1

Description

@BleethNie
  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; 最小值回跳操作

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions