From dba60f03ae93088a5783ec0306f2dd1684aff47a Mon Sep 17 00:00:00 2001 From: shellhub Date: Mon, 12 Apr 2021 16:24:11 +0800 Subject: [PATCH] selection sort optimization --- .../\347\256\227\346\263\225 - \346\216\222\345\272\217.md" | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git "a/notes/\347\256\227\346\263\225 - \346\216\222\345\272\217.md" "b/notes/\347\256\227\346\263\225 - \346\216\222\345\272\217.md" index edd086c1d9..b4c9ed52d1 100644 --- "a/notes/\347\256\227\346\263\225 - \346\216\222\345\272\217.md" +++ "b/notes/\347\256\227\346\263\225 - \346\216\222\345\272\217.md" @@ -45,7 +45,9 @@ public class Selection> extends Sort { min = j; } } - swap(nums, i, min); + if (min != i) { + swap(nums, i, min); + } } } }