Question: Write a C program for the following problem. There are n items in the suitcase of a traveler. On boarding the flight, the airline company

Write a C program for the following problem. There are n items in the suitcase of a traveler. On boarding the flight, the airline company told him that his suitcase is over weight than the allowed capacity W and asked him deload some items and not to carry more than W. He knows weight of each item and knows the priority (like which item is the most, next most, etc.). Devise an algorithm to find out which items to be discarded based on priority (1-high priority, 2-next high priority and so on) so that he can carry max. weight W (assume the weight of the suitcase is ignored). For example, Weights : 1078 4, Priority: 1 3 4 2 and W=16, the output is 1 0 0 1 Weights: 4723 Priority: 41 2 3 and W=10, the output is 0 1 1 0 Note: Read number of items, weights of items, priorities of items and knapsack capacity 18m the user. Print the solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
