-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathquicksortM3insertion.c
More file actions
37 lines (32 loc) · 924 Bytes
/
Copy pathquicksortM3insertion.c
File metadata and controls
37 lines (32 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Copyright(C) 2020, Bruno César Ribas <bruno.ribas@unb.br>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include "ordenacaomacros.h"
#include "quicksortM3insertion.h"
#include "insertionsort.h"
#include "separa.h"
static void quicksortM3(Item *V,int l, int r)
{
if (r-l<=32) return;
exch(V[(l+r)/2],V[r-1]);
cmpexch(V[l],V[r-1]);
cmpexch(V[l],V[r]);
cmpexch(V[r-1],V[r]);
int j=separa(V,l+1,r-1);
quicksortM3(V,l,j-1);
quicksortM3(V,j+1,r);
}
void quicksortM3insertion(Item *V,int l,int r)
{
quicksortM3(V,l,r);
insertionsort(V,l,r);
}