Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider two possible investments A and B; each year, an oracle tells you the return of the investments for the each of the n next
Consider two possible investments A and B; each year, an oracle tells you the return of the
investments for the each of the n next years. This can be represented by arrays A a an
and B b bnyou can assume that these are always correct At the beginning of each year
i you can place all your investment money entirely in A or entirely in B It is guaranteed that
your money should multiply by ai if you invested in A or by bi if you invested in B by the end
of year i However, if you move your money from A to B or B to A when transitioning to the next
year, you lose half your money.
Given the return on investments for the next n years as arrays of multipliers A a an
and B b bn design an algorithm to determine the maximum multiplier you can achieve
on your initial investment by the end of year n
Example: Lets say that A and B You should place your money in
investment A in years and to have your initial investment multiply by Then,
you would transfer your money from A to B which would cut your money in half now you only
have a x multiplier on your initial investment By the end of year you would achieve a x
multipler on your initial investment. Your algorithm should return in this case.
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