In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Merge sort is also called merger sort. The algorithm idea is to divide the sequence to be sorted into two parts, then apply merge sort to the two parts in sequence, and then stop the merger. It would be very general to understand the merge sorting only from the algorithmic idea, and then use the sequence A [0], A [l]. A [n-1] stops the ascending order display to stop the explanation, and here takes a top-down approach, with the following steps.
(1) divide the sorting sequence you want to stop into two parts. If the starting element of the sequence to stop sorting is subscript first, and the subscript of the first element is last, then the critical subscript mid= (first+last) / 2 between the two parts of you is A [first... Mid] and A [mid + 1 … Last] .
(2) the two local sequences divided below are continuously divided according to the step (1) until the length of the interval is 1.
(3) stop merging and sorting the divided sequences, and the sorting method is to stop merging n sub-sequences, lose n-bank 2 or n-bank 2 subsequences containing two elements, and then stop merging the lost sub-sequences until an ordered sequence of length n is lost. Let's go through a piece of code to see how to complete the merge sort.
# include # include # define N 7 void merge (int arr [], int low, int mid, int high) {int I, k; int * tmp = (int *) malloc ((high-low+1) * sizeof (int)); / / request space with the size of two int left_low = low; int left_high = mid; int right_low = mid + 1; int right_high = high; for (kryp0; left_low)
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.