Title: 【0097_Week07】学习总结 · Issue #1270 · algorithm005-class02/algorithm005-class02 · GitHub
Open Graph Title: 【0097_Week07】学习总结 · Issue #1270 · algorithm005-class02/algorithm005-class02
X Title: 【0097_Week07】学习总结 · Issue #1270 · algorithm005-class02/algorithm005-class02
Description: /** * 选择排序 * * @param arr */ public void selectSort(int[] arr) { if (arr.length == 0) return; int maxIndex; for (int i = 0; i < arr.length; i++) { maxIndex = i; for (int j = i + 1; j < arr.length - i; i++) { if (arr[j] > arr[maxIndex]) {...
Open Graph Description: /** * 选择排序 * * @param arr */ public void selectSort(int[] arr) { if (arr.length == 0) return; int maxIndex; for (int i = 0; i < arr.length; i++) { maxIndex = i; for (int j = i + 1; j < arr.length -...
X Description: /** * 选择排序 * * @param arr */ public void selectSort(int[] arr) { if (arr.length == 0) return; int maxIndex; for (int i = 0; i < arr.length; i++) { maxIndex = i; for (int j = i + 1; j < arr.le...
Opengraph URL: https://github.com/algorithm005-class02/algorithm005-class02/issues/1270
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"【0097_Week07】学习总结","articleBody":"/**\r\n * 选择排序\r\n *\r\n * @param arr\r\n */\r\n public void selectSort(int[] arr) {\r\n if (arr.length == 0) return;\r\n int maxIndex;\r\n for (int i = 0; i \u003c arr.length; i++) {\r\n maxIndex = i;\r\n for (int j = i + 1; j \u003c arr.length - i; i++) {\r\n if (arr[j] \u003e arr[maxIndex]) {\r\n maxIndex = j;\r\n }\r\n }\r\n int tmp = arr[arr.length - i];\r\n arr[arr.length - i] = arr[maxIndex];\r\n arr[maxIndex] = tmp;\r\n }\r\n }\r\n\r\n /**\r\n * 插入排序\r\n *\r\n * @param arr\r\n */\r\n public void insertSort(int[] arr) {\r\n if (arr.length \u003c= 1) return;\r\n for (int i = 1; i \u003c arr.length; i++) {\r\n int preIndex = i - 1, current = arr[i];\r\n while (preIndex \u003e= 0 \u0026\u0026 arr[preIndex] \u003e current) {\r\n arr[preIndex + 1] = arr[preIndex];\r\n preIndex--;\r\n }\r\n arr[preIndex + 1] = current;\r\n }\r\n }\r\n\r\n /**\r\n * 冒泡排序\r\n *\r\n * @param arr\r\n */\r\n public void bubbleSort(int[] arr) {\r\n if (arr.length == 0) return;\r\n for (int i = 0; i \u003c arr.length; i++) {\r\n for (int j = i + 1; j \u003c arr.length; j++) {\r\n if (arr[i] \u003e arr[j]) {\r\n int t = arr[i];\r\n arr[i] = arr[j];\r\n arr[j] = t;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 快速排序\r\n *\r\n * @param arr\r\n * @param begin\r\n * @param end\r\n */\r\n public void quickSort(int[] arr, int begin, int end) {\r\n if (begin \u003e= end) return;\r\n int pivot = partition(arr, begin, end);\r\n quickSort(arr, begin, pivot - 1);\r\n quickSort(arr, pivot + 1, end);\r\n\r\n }\r\n\r\n public int partition(int[] arr, int begin, int end) {\r\n int pivot = end, count = begin;\r\n for (int i = begin; i \u003c end; i++) {\r\n if (arr[i] \u003c arr[pivot]) {\r\n int tmp = arr[i];\r\n arr[i] = arr[count];\r\n arr[count] = tmp;\r\n count++;\r\n }\r\n }\r\n int tmp = arr[pivot];\r\n arr[pivot] = arr[count];\r\n arr[count] = tmp;\r\n return count;\r\n }\r\n\r\n /**\r\n * 归并排序\r\n *\r\n * @param arr\r\n * @param left\r\n * @param right\r\n */\r\n public void mergeSort(int[] arr, int left, int right) {\r\n if (arr.length \u003c= 1) return;\r\n if (right \u003c= left) return;\r\n int mid = (left + right) \u003e\u003e 1;\r\n mergeSort(arr, left, mid);\r\n mergeSort(arr, mid + 1, right);\r\n merge(arr, left, mid, right);\r\n }\r\n\r\n /**\r\n * 归并排序的合并\r\n *\r\n * @param arr\r\n * @param left\r\n * @param mid\r\n * @param right\r\n */\r\n public void merge(int[] arr, int left, int mid, int right) {\r\n int[] temp = new int[right - left + 1];\r\n int i = left, j = mid + 1, k = 0;\r\n while (i \u003c= mid \u0026\u0026 j \u003c= right) {\r\n temp[k++] = arr[i] \u003e= arr[j] ? arr[i++] : arr[j++];\r\n }\r\n while (i \u003c= mid) temp[k++] = arr[i++];\r\n while (j \u003c= right) temp[k++] = arr[k++];\r\n for (int t = 0; t \u003c temp.length; t++) {\r\n arr[left + t] = temp[t];\r\n }\r\n }","author":{"url":"https://github.com/JiangJiang77","@type":"Person","name":"JiangJiang77"},"datePublished":"2020-03-01T09:25:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1270/algorithm005-class02/issues/1270"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7222839a-b191-3a54-8cee-a3fb6a616d41 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7B2:22E260:2A7A6D4:3919680:697050FC |
| html-safe-nonce | 534a663f0bb02b153d0c8eaf799fd2137bace0ba1c01778eac0f30adebacfe81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0IyOjIyRTI2MDoyQTdBNkQ0OjM5MTk2ODA6Njk3MDUwRkMiLCJ2aXNpdG9yX2lkIjoiODc1OTQyNjQ4MDE0OTEyMzMyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0c864e815dc33adde36de44162d9124be1e928f03b09c742f018aee34783a31d |
| hovercard-subject-tag | issue:573513677 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/algorithm005-class02/algorithm005-class02/1270/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0213d36937d5fb0e8776f2028c0084f1663078c4ad6eae6f93dfc0ca1275681b/algorithm005-class02/algorithm005-class02/issues/1270 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0213d36937d5fb0e8776f2028c0084f1663078c4ad6eae6f93dfc0ca1275681b/algorithm005-class02/algorithm005-class02/issues/1270 |
| og:image:alt | /** * 选择排序 * * @param arr */ public void selectSort(int[] arr) { if (arr.length == 0) return; int maxIndex; for (int i = 0; i < arr.length; i++) { maxIndex = i; for (int j = i + 1; j < arr.length -... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JiangJiang77 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/algorithm005-class02/algorithm005-class02 git https://github.com/algorithm005-class02/algorithm005-class02.git |
| octolytics-dimension-user_id | 58394351 |
| octolytics-dimension-user_login | algorithm005-class02 |
| octolytics-dimension-repository_id | 225177649 |
| octolytics-dimension-repository_nwo | algorithm005-class02/algorithm005-class02 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 225177649 |
| octolytics-dimension-repository_network_root_nwo | algorithm005-class02/algorithm005-class02 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f643964067a552f02067066d6a910b2f90a5721f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width