Question 5: Marbles 5 marks This question requires solving an optimization grid below, where some grid...
Question 5: Marbles 5 marks This question requires solving an optimization grid below, where some grid cells contain a marble. based on a simple game. Consider the 5 x5 proble Starting from an initial grid (which can be represented by a 2d array of boolean values in a program), A marble can be removed from the grid if and only if there is at least one other marble in the same row or column of the marble to be removed. which marbles are removed marbles can be The order affect how noved in total. For example, starting from the grid above, the following seouence of movesc remove 3 marbles where the marble to be removed is highlighted in red at each step) However, with the sequencee of moves below, it is possible to remove six marbles. Design an algorithm MARBLES to solve the following problem. f boolean values, where Al= true if there is a t can be removed from the grid Input: marble i row i column Output: under the rules above. Notice that your algorithm does not have to find the sequence of marbles to remove, just report the maximum mumber of marbles that can be removed (which should make the problem easier), It is sufficient to provide a high level description of the algorithm instead of peeudocode (e.g. describe code for theee stans) You must include a instification of the corrtss of wour alaorit bm For ful marks, your algorit hm must run in O(n2) time in the worst case.