In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.