Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
progsec20233
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stephane.chappuis1
progsec20233
Commits
2158afb2
Commit
2158afb2
authored
1 year ago
by
stephane.chappuis1
Browse files
Options
Downloads
Patches
Plain Diff
ajout merge sort
parent
ce19254e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
MergeSort.c
+63
-0
63 additions, 0 deletions
MergeSort.c
with
63 additions
and
0 deletions
MergeSort.c
0 → 100644
+
63
−
0
View file @
2158afb2
#include
"./MergeSort.h"
void
merge
(
int
tab
[],
int
l
,
int
m
,
int
r
)
{
int
i
,
j
,
k
;
int
n1
=
m
-
l
+
1
;
int
n2
=
r
-
m
;
int
L
[
n1
],
R
[
n2
];
for
(
i
=
0
;
i
<
n1
;
i
++
)
L
[
i
]
=
tab
[
l
+
i
];
for
(
j
=
0
;
j
<
n2
;
j
++
)
R
[
j
]
=
tab
[
m
+
1
+
j
];
i
=
0
;
j
=
0
;
k
=
l
;
while
(
i
<
n1
&&
j
<
n2
)
{
if
(
L
[
i
]
<=
R
[
j
])
{
tab
[
k
]
=
L
[
i
];
i
++
;
}
else
{
tab
[
k
]
=
R
[
j
];
j
++
;
}
k
++
;
}
while
(
i
<
n1
)
{
tab
[
k
]
=
L
[
i
];
i
++
;
k
++
;
}
while
(
j
<
n2
)
{
tab
[
k
]
=
R
[
j
];
j
++
;
k
++
;
}
}
void
merge_sort
(
int
size
,
int
tab
[
size
])
{
int
l
=
0
;
int
r
=
size
-
1
;
if
(
l
<
r
)
{
int
m
=
l
+
(
r
-
l
)
/
2
;
merge_sort
(
m
-
l
+
1
,
tab
);
merge_sort
(
r
-
m
,
tab
);
merge
(
tab
,
l
,
m
,
r
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment