-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsorting.py
More file actions
47 lines (35 loc) · 1.58 KB
/
sorting.py
File metadata and controls
47 lines (35 loc) · 1.58 KB
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
38
39
40
41
42
43
44
45
46
47
def initialize_matrix(n: int) -> list[list[int]]:
"""
A function that takes an integer n as an argument and returns a 2D array of size n x n with each cell containing None values.
"""
pass
def length(arr: list[int]) -> int:
"""
A function that takes a single-dimensional array, arr, as an argument and returns the count of valid data items in it, i.e., the non-None values.
"""
pass
def get_maximum(arr: list[int]) -> int:
"""
A function that takes an array as an argument, and WITHOUT using the built-in functions, returns the maximum value of the array.
"""
pass
def insertion_sort(arr: list[int]) -> None:
"""
A void function that takes a single-dimensional array arr as an argument and applies insertion sort on the valid data items in the array, i.e., the non-None values. This is an in-place function, meaning the original array that was passed as a reference will be updated with the sorted values.
The function should not return anything.
"""
pass
def partition_and_prevail(arr: list[int]) -> None:
"""
A void function that takes the array to be sorted as an argument
and applies the “Partition and Prevail” algorithm to sort the valid
data items in the array, as explained in the assignment.
The function should not return anything.
"""
pass
def main(filename) -> list[int]:
"""
- Take input from the given filename one line at a time
- Apply partition_and_prevail sorting algorithm to get the sorted arrays and returns the output as a one dimensional array.
"""
pass