Assignment 3
Deadline: Nov. 25th, 2022, CET
Exercises
3.1 Find kth highest element in an unsorted list
Using ideas from the quick-sort algorithm, find the kth highest element in an unsorted list. If there are duplicates in your list, they should occupy the same rank. In case there is not kth element, your function should return None
.
For example, given the list [6, 5, 3, 3, 4]
, the function should return:
- 6 for
k = 1
- 5 for
k = 2
- 4 for
k = 3
- 3 for
k = 4
None
fork >= 5
You are not allowed to use any function that sorts your input!
Note: We are including two test files which are exactly the same: one uses pytest, while the other one contains the same tests as unittests in case you have trouble running pytest.
Wrapping up
Do not forget to
- indicate your name(s) in the file header
- add the honor code (I/We pledge that this code represents my/our own work)
- commit all your changes
- push it to your GitHub repository