Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You have n cards. Each card has two non-negative integers, ai and bi. There is a counter c indicating how many cards can be played.
You have n cards. Each card has two non-negative integers, ai and bi. There is a counter c indicating how many cards can be played. At the the beginning of the game, c 1. Every time you play a card, you get ai points and also get the opportunity to play bi additional cards. Specifically, every time you play a card, c-c-1 +bi (-1 for playing a card, +b, for the card you played). The game is over when c 0 or all cards have been played. Design a greedy algorithm to find the maximum possible points you can get, and prove the correctness of your algorithm. Hint: one of the two following problems can be solved using a greedy algorithm, the other cannot. Recall that greedy algorithms are faster than dynamic pro- gramming algorithms, so you should always try to solve with a greedy algorithm when possible
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started