5. [2 marks] Can we do higher than this? Recall that the human participant is at some fastened location (px, py). Your job is to work out how you’d kind the array A in order that these enemy AIs that must be marked will be recognized in log(N) time. Particularly, full the next comparability perform that may be used whereas sorting the array A. Right here, (x1, y1) and (x2, y2) are two factors from the array A. The perform ought to return true if it considers the primary level to be lower than or equal to the second, and ought to return false in any other case. Your perform can use the participant’s coordinate (px, py) as international variables, i.e. you’re allowed to check with px and py in your perform. 2 perform LessOrEqualTo((x1, y1),(x2, y2)) . . . 6. [3 marks] Now, supposing the array has been sorted utilizing your comparability perform, implement an algorithm whose worst case complexity is in Θ(log(N)) that determines which array parts must be marked. Your perform ought to take the sure b as an argument, and may take the participant’s coorinates (px, py). 

Published by
Write
View all posts