Quiz Space

Advanced Algorithms · Quiz 1 · 7 Jul 2024 · May 2024 term

Question 5: Alice and Bob play the following game using an array a of…

Question 5

+2 marksOne correct option

Alice and Bob play the following game using an array aa of nn integers:

  1. Players take turns, Alice moves first.
  2. Each turn a player chooses any element and removes it from the array.
  3. If Alice chooses even value, then she adds it to her score. If the chosen value is odd, Alice's score does not change.
  4. Similarly, if Bob chooses odd value, then he adds it to his score. If the chosen value is even, then Bob's score does not change.

If there are no numbers left in the array, then the game ends. The player with the highest score wins. If the scores of the players are equal, then a draw is declared.

For example, if n=4n = 4 and a=[5,2,7,3]a = [5, 2, 7, 3], then the game could go as follows (there are other options):

  1. On the first move, Alice chooses 2 and get two points. Her score is now 2 . The array aa is now [5,7,3][5, 7, 3].
  2. On the second move, Bob chooses 5 and get five points. His score is now 5. The array aa is now [7,3].
  3. On the third move, Alice chooses 7 and get no points. Her score is now 2. The array aa is now [3].
  4. On the last move, Bob chooses 3 and get three points. His score is now 8 . The array aa is empty now.
  5. Since Bob has more points at the end of the game, he is the winner.

You want to find out who will win if both players play optimally.

Note that there may be duplicate numbers in the array.

To play optimally means to play to force a win whenever possible.
Based on the above data answer the given subquestions.

  1. A

    Alice

  2. B

    Bob

  3. C

    Draw

Show answer

Correct answer

  • A

    Alice

Question 5 of 26 in the IIT Madras BS Advanced Algorithms (Advanced Algorithms) Quiz 1 paper sat on 7 Jul 2024, in the May 2024 term (IIT M DEGREE AN EXAM QDB2 7 July 2024). It carries 2 marks.

More questions from this paper

  1. Q1There are 2n positive integers written on a whiteboard. Here is a one-player game with these numbers: You start with a …
  2. Q2There are 2n positive integers written on a whiteboard. Here is a one-player game with these numbers: You start with a …
  3. Q3There are 2n positive integers written on a whiteboard. Here is a one-player game with these numbers: You start with a …
  4. Q4There are 2n positive integers written on a whiteboard. Here is a one-player game with these numbers: You start with a …
  5. Q6Alice and Bob play the following game using an array a of n integers: Players take turns, Alice moves first. Each turn …
  6. Q7Alice and Bob play the following game using an array a of n integers: Players take turns, Alice moves first. Each turn …
  7. Q8Alice and Bob play the following game using an array a of n integers: Players take turns, Alice moves first. Each turn …
  8. Q9Alice and Bob play the following game using an array a of n integers: Players take turns, Alice moves first. Each turn …
  9. Q10Alice and Bob play the following game using an array a of n integers: Players take turns, Alice moves first. Each turn …
  10. Q11Based on the above data answer the given subquestions.
  11. Q12Based on the above data answer the given subquestions.
  12. Q13Based on the above data answer the given subquestions.
  13. Q14There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  14. Q15There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  15. Q16There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  16. Q17There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  17. Q18There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  18. Q19There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  19. Q20There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  20. Q21There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  21. Q22There are N flowers arranged in a row. For each i(1 \leq i \leq n), the height and the beauty of the i-th flower from t…
  22. Q23How many cops are necessary and sufficient to catch the robber on a path?
  23. Q24How many cops are necessary and sufficient to catch the robber on a tree?
  24. Q25How many cops are necessary and sufficient to catch the robber on a cycle?
  25. Q26How many cops are definitely enough to catch the robber on a graph of treewidth k?