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

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

Share this

Related Posts

Previous
Next Post »