Question: Algorith Analysis Question we want to make a stamp collection album. There are a total of n distinct stamps available for us to buy in

Algorith Analysis Question

we want to make a stamp collection album. There are a total of n distinct stamps available for us to buy in town, numbered with integers from 0 to n 1. There are two stores in the town, namely A and B that sells stamps and all n stamps are available in both stores. Store A sells stamp i for a[i ] dollars, where store B sells the same for b[i ] dollars. we can spend at most x dollars in store A and at most y dollars in store B. we want to buy as many different stamps as he can given budget constraint. Notice that we will not buy two copies of the same stamp.

give an algorithm with; Two integer arrays a[0, . . . ,n1] and b[0, . . . ,n1] of size n such that for each i , a[i ] and b[i ] represent the cost of buying stamp i from store A and store B, respectively. Two integers x and y that represent the amount of money can spend in store A and store B, respectively. Algorithm should return the maximum number of distinct stamps can buy with money. The running time of your algorithm should be O(n x y).

I would be very grateful if you could explain it step by step.

Thanks in advance.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!