# COMP90038 Algorithms and Complexity – Best Writing Service

The University of MelbourneSchool of Computing and Information SystemsCOMP90038 and ComplexityAssignment 1, Semester 2 2019Released: Friday August 23 2019. Deadline: Sunday September 8 2019 23:59This assignment is marked out of 30 and is worth 15% of your grade for .ObjectivesTo improve your understanding of the time of and recurrence relations. To developproblem-solving and design skills. To improve written communication skills; in particular the ability topresent clearly, precisely and unambiguously.ProblemsLet’s play a game. Or, more precisely, design and analyse some that might be used in a simpletwo-dimensional (2D) game.Figure 1: A tiny example game scenario. Enemy (AI-controlled) players are shown in blue. The fixedlocation of the human player is marked by the red cross.Consider a game played on an two-dimensional grid, whose Cartesian coordinates range from(-M; M) : : : (M; M). Figure 1 depicts a game board for which M = 4.The game contains a fixed number N of enemy players, who are AI-controlled. Each player (includingthe human player and each enemy AI) is located at some arbitrary but fixed position (x; y) on the board,i.e. for which -M ≤ x ≤ M and -M ≤ y ≤ M.The human player can perform certain attacks, which damage all enemy players within a certainrange of the human player. To avoid the need to calculate with expensive multiplication and square rootoperations, we will approximate the range by a square situated about the human player.1Specifically, given some fixed bound b, for which 0 ≤ b ≤ M, if the human player is located at position(px; py) then all enemy players that lie within or on the borders of the box whose bottom-left corner is(px – b; py – b) and whose top-right corner is (px + b; py + b) are affected by the attack. Figure 1 depictsan example box for the bound b = 1:5.1. [1 mark] Implement an Θ(1) function to determine whether an enemy at position (x; y) is affectedby the player’s attack, given the player’s location (px; py):function IsAffected((px; py); (x; y); b). . .2. [2 marks] Suppose (for now) that the positions of the enemy players are stored in an unsorted arrayA[0] : : : A[N – 1].The following function uses the divide and conquer approach to mark all enemy players affected bya player attack. Marking is implemented by the Mark function whose details are not important.(Note: the division below is integer division, i.e. it rounds down to the nearest integer.)function MarkAffected((px; py); A; b)MarkAffectedDC((px; py); A; 0; N – 1; b)
function MarkAffectedDC((px; py); A; lo; hi; b)if lo = hi then
. assume lo ≤ hi
Australian Expert Writers