Question: Problem 6 . ImportExport ( A , B ) Input: Two arrays A [ 0 . . . n 1 ] and B [ 0
Problem ImportExportAB
Input: Two arrays A n and B n both of length n representing the prices of tulips in
country A and country B at different times, respectively. All entries in both arrays are positive integers.
Output: Return the maximum possible profit, defined as:
max
ji Bj Ai
or return if all such Bj Ai are negative. You only need to return the value of the maximum profit,
not the actual indices i and j
Example:
Given the input:
A
B
The maximum possible profit is achieved by buying tulips at time i when A and selling them
at time j when B which gives a profit of:
B A
Therefore, the output is
Give pseudocode for a recursive Ontime algorithm for ImportExportAB
Give pseudocode for a Ontime dynamic programming algorithm for ImportExportAB
Solution. The solution to Problem goes here.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
