You are given an exam with questions numbered 1, 2, 3, . . . , n. Each question i is worth pi points and has a frustration score fi . You must answer the questions in order, but you may choose to skip some questions. The reason you might choose to do this is that even though you can solve any individual question i and obtain the ???? points, some questions are so frustrating that after solving them you will be unable to solve any of the following fi questions. Suppose that you are given the pi and fi values for all the questions as input. Devise an efficient algorithm you can for choosing a set of questions to answer that maximizes your total points, and compute its asymptotic worst case running time as a function of n.
You are given an exam with questions numbered 1, 2, 3, . . . , n. Each question i is worth
pi points and has a frustration score fi . You must answer the questions in order, but
you may choose to skip some questions. The reason you might choose to do this is that
even though you can solve any individual question i and obtain the ???? points, some
questions are so frustrating that after solving them you will be unable to solve any of the
following fi questions. Suppose that you are given the pi and fi values for all the
questions as input. Devise an efficient
to answer that maximizes your total points, and compute its asymptotic worst case
running time as a function of n.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps