In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you what the merge sort is in the C# sorting algorithm, which is concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Code:
/ / merge sort (target array, start position of the child table, end position of the child table) private static void MergeSortFunction (int [] array, int first, int last) {try {if (first < last) / / the length of the child table is greater than 1, enter the following recursive processing {int mid = (first + last) / 2; / / the position of the subtable partition MergeSortFunction (array, first, mid) / / A pair of left subtables are divided recursively into MergeSortFunction (array, mid + 1, last); / / A pair of right subtables are divided recursively into MergeSortCore (array, first, mid, last) / / an ordered consolidation of left and right child tables (the core of merge sorting)}} catch (Exception ex) {}} / / the core of merge sorting: merge two ordered left and right child tables (distinguished by mid) into an ordered table private static void MergeSortCore (int [] array, int first, int mid, int last) {try {int indexA = first; / / the starting position of the left child table int indexB = mid + 1 / / the starting position of the right child table int [] temp = new int [last + 1]; / / declare the array (temporarily storing all ordered sequences of the left and right child tables): the length is equal to the sum of the lengths of the left and right child tables. Int tempIndex = 0; while (indexA
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.