Question: Sometimes a small change in a problem can make a BIG change in how to solve the problem. Here is an example of this phenomenon.

Sometimes a small change in a problem can make a BIG change in how to solve the problem. Here is an example of this phenomenon. Assume you have a group of packages, each of which has its weight marked on the outside of the package. For some reason, you are asked to separate the group into two subgroups such that the difference between the total weight of the packages in each group is a maximum. Hopefully after you think about this problem, the elegantly simple solution occurs to you: find the smallest package, and make that single package the first group; make all the remaining packages the second group. This constitutes the two groups with the largest possible difference. This algorithm has complexity of big-theta (N), where N is the number of packages. (NOTE: if there is a tie for smallest package, pick one of the packages with that smallest weight to be by itself in the first group.) Now, heres the small change in the problem: instead of finding two groups with the BIGGEST difference in weights, find two groups that have the SMALLEST difference in weights. After you tell me your algorithm (you can use pseudo-code or an actual programming language), tell me the big-theta for your program in terms of N, the number of packages. Warning: if you think the correct algorithm is linear, your algorithm isnt right.

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!