In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you the content of the example analysis of fast sorting in c # The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Quick sorting is also one of our algorithms. The sorting method is relatively fast, and basically decreases at the speed of numbers (where m is the number of elements in the set). Its core idea is to exchange the positions of large numbers and decimal numbers.
The main steps are as follows:
(1) prepare an unordered set of at least two elements
(2) like dichotomy, the initial index (starindex), the end index (endindex) and the median index (middleindex) and the median index (middle) are obtained.
(3) find the first number larger than the median in the whole array and write down the position (highindex) At the same time, find the first number smaller than the median from back to front and position (lowindex); if highindex=endIndex) {return;} int highIndex = startIndex; int lowIndex = endIndex; / / use the median index to get the median int middle = ary [(startIndex + endIndex) / 2] While (true) {/ / find the first number larger than the median from the back, and immediately end the loop for (int I = highIndex; I = middle) {/ / get the position of the first number larger than the median highIndex = I Break;}} / / find the first number smaller than the median from back to front, and end the loop for (int I = lowIndex; I > = startIndex) as soon as you find it. IMel -) {if (ary [I] = lowIndex means that there is no number larger than the median before the median, and not so long after the median is smaller than the median. End up looking for if (highIndex > = lowIndex) {break } / / the position of the first large number before the median and the first decimal after the median int temp=ary [highIndex]; ary [highIndex] = ary [lowIndex]; ary [lowIndex] = temp; lowIndex-- / / next search continues to find a number smaller than the median from the previous bit of the location highIndex++;// next search continues to look for a number larger than the median from the latter bit of the location} / / divides the array into two parts to search separately until the whole array is ordered QuickSort (ary, startIndex, highIndex-1) QuickSort (ary, lowIndex + 1, endIndex);} Thank you for reading! This is the end of this article on "sample analysis of fast sorting in c #". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.