Breaking News
Loading...
Tuesday, July 9, 2013

Thuật Toán InsertionSort Theo Phương Pháp Đệ Quy

7/09/2013 11:18:00 PM

Thuật toán InsertionSort Theo Phương Pháp Đệ Quy


void Insert(int a[], int N, int x)
{
   if (N < 1 || a[N - 1] <= x) {
       a[N] = x;
       return;
   }
   a[N] = a[N - 1];
   Insert(a, N - 1, x);
}

void InsertionSort(int a[], int N)
{
   if (N <= 1)
       return;
   InsertionSort(a, N - 1);
   Insert(a, N - 1, a[N - 1]);
}

Thuật toán InsertionSort không đệ quy Tại đây

0 comments:

Post a Comment

 
Toggle Footer