repositories
/
Algorithmic_C.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a7c59b0
)
Refinements to quick sort implementation
author
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Fri, 3 Mar 2017 17:28:43 +0000
(18:28 +0100)
committer
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Fri, 3 Mar 2017 17:28:43 +0000
(18:28 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP3/tp3.c
patch
|
blob
|
blame
|
history
diff --git
a/TP3/tp3.c
b/TP3/tp3.c
index 4caf275dff9aea2e78dbd06d88a0dd38c29bb9e3..9198ad1e15ba4e245b857e124f170b28e609ee4f 100644
(file)
--- a/
TP3/tp3.c
+++ b/
TP3/tp3.c
@@
-7,13
+7,14
@@
void AfficheTab(int T[], int n) {
}
}
+/** This quick sort implementation only work with 2^n array size */
void TriFusion(int T[], int n) {
int i = 0, j = 0, k = 0;
int* T1;
int* T2;
T1 = malloc(n/2*sizeof(int));
- T2 = malloc(
(n - n/2)
*sizeof(int));
+ T2 = malloc(
n/2
*sizeof(int));
if (n > 1) {
for (int i = 0; i < n/2; i++) {
@@
-49,7
+50,7
@@
void TriFusion(int T[], int n) {
}
int main() {
- int T[] = {
4, 2, 7, 3, 8, 1, 6
, 5};
+ int T[] = {
2, 7, 2, 3, 4, 1, 5
, 5};
int tabSize = sizeof(T)/sizeof(T[0]);
AfficheTab(T, tabSize);