Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-Dahmane-lynda
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lynda Dahmane
AP-Dahmane-lynda
Commits
8deb6d32
Commit
8deb6d32
authored
1 year ago
by
Dahmane Lynda
Browse files
Options
Downloads
Patches
Plain Diff
tris-fusion
parent
cf412c1a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tp9/tri-fusion.zip
+0
-0
0 additions, 0 deletions
Tp9/tri-fusion.zip
Tp9/tri-fusion/merge_sort.py
+14
-5
14 additions, 5 deletions
Tp9/tri-fusion/merge_sort.py
with
14 additions
and
5 deletions
Tp9/tri-fusion.zip
0 → 100644
+
0
−
0
View file @
8deb6d32
File added
This diff is collapsed.
Click to expand it.
Tp9/tri-fusion/merge_sort.py
+
14
−
5
View file @
8deb6d32
...
@@ -122,7 +122,18 @@ def is_sorted(l: ApLst, comp: Callable[[T, T], int]=compare) -> bool:
...
@@ -122,7 +122,18 @@ def is_sorted(l: ApLst, comp: Callable[[T, T], int]=compare) -> bool:
$$$ is_sorted(native_to_list([1, 2, 4, 3]))
$$$ is_sorted(native_to_list([1, 2, 4, 3]))
False
False
"""
"""
...
if
l
.
is_empty
():
return
True
else
:
if
l
.
tail
().
is_empty
():
return
True
else
:
if
comp
(
l
.
head
(),
l
.
tail
().
head
())
>
0
:
return
False
else
:
return
is_sorted
(
l
.
tail
(),
comp
)
def
split
(
l
:
ApLst
)
->
tuple
[
ApLst
,
ApLst
]:
def
split
(
l
:
ApLst
)
->
tuple
[
ApLst
,
ApLst
]:
...
@@ -141,8 +152,7 @@ def split(l: ApLst) -> tuple[ApLst, ApLst]:
...
@@ -141,8 +152,7 @@ def split(l: ApLst) -> tuple[ApLst, ApLst]:
$$$ all(k in l for k in l3)
$$$ all(k in l for k in l3)
True
True
"""
"""
...
def
merge
(
l1
:
ApLst
,
l2
:
ApLst
,
def
merge
(
l1
:
ApLst
,
l2
:
ApLst
,
comp
:
Callable
[[
T
,
T
],
int
]
=
compare
)
->
ApLst
:
comp
:
Callable
[[
T
,
T
],
int
]
=
compare
)
->
ApLst
:
...
@@ -156,8 +166,7 @@ def merge(l1: ApLst, l2: ApLst,
...
@@ -156,8 +166,7 @@ def merge(l1: ApLst, l2: ApLst,
$$$ list_to_native(merge(native_to_list([1, 3, 4, 9]), native_to_list([1, 2, 5])))
$$$ list_to_native(merge(native_to_list([1, 3, 4, 9]), native_to_list([1, 2, 5])))
[1, 1, 2, 3, 4, 5, 9]
[1, 1, 2, 3, 4, 5, 9]
"""
"""
...
def
mergesort
(
l
:
ApLst
,
comp
:
Callable
[[
T
,
T
],
int
]
=
compare
)
->
ApLst
:
def
mergesort
(
l
:
ApLst
,
comp
:
Callable
[[
T
,
T
],
int
]
=
compare
)
->
ApLst
:
"""
"""
...
...
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