Asp.net C # Merge Sorting Algorithm Implementation

Source: Internet
Author: User

Asp tutorial. net c # Merge Sorting Algorithm Implementation
[Merge Sorting] Algorithm Implementation

I: Start position of the first sequence when merging starts;

S: the size of the pre-merging sequence;

T: size of the merged Sequence

I, I + s-1, I + T-1 defines the boundary of the two merged sequences.
 

1 // apply the merge algorithm of the previous article to sort Arrays
2 /************************************** ******************************/
3/*********************** [Merge Sorting Algorithm ]********* *********************/
4 /************************************** ******************************/
5 void sort_merge (int array [], int size)
6 {
7 int I; // start position of the first sequence when the merge starts
8 int s; // the size of the pre-merging Sequence
9 int t = 1; // size of the merged Sequence
10
11 while (t <size)
12 {
13 I = 0;
14 s = t;
15 t = 2 * s;
16 while (I + t) <size)
17 {
18 merge (array, I, I + s-1, I + T-1, t); // see merging two subordered array algorithms in the previous article
19 I = I + t;
20}
21 if (I + s <size)
22 {
23 merge (array, I, I + s-1, size-1, size-I );
24}
25}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.