diff --git a/Tp9/tri-fusion.zip b/Tp9/tri-fusion.zip new file mode 100644 index 0000000000000000000000000000000000000000..213bf6afce46009d00a347818b101145210f10bc Binary files /dev/null and b/Tp9/tri-fusion.zip differ diff --git a/Tp9/tri-fusion/merge_sort.py b/Tp9/tri-fusion/merge_sort.py index bd14992ba35492b0327f33f03b485e28cfb570bb..18fd323342f87e7c1ef2b48eb0b7ca5908dd1d78 100755 --- a/Tp9/tri-fusion/merge_sort.py +++ b/Tp9/tri-fusion/merge_sort.py @@ -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])) 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]: @@ -141,8 +152,7 @@ def split(l: ApLst) -> tuple[ApLst, ApLst]: $$$ all(k in l for k in l3) True """ - ... - + def merge(l1: ApLst, l2: ApLst, comp: Callable[[T, T], int]=compare) -> 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]))) [1, 1, 2, 3, 4, 5, 9] """ - ... - + def mergesort(l: ApLst, comp: Callable[[T, T], int]=compare) -> ApLst: """