This problem has been solved!
You'll get a detailed solution from a subject matter expert that helps you learn core concepts.
See AnswerQuestion: Question1You are given a set of n items, where each item i has1 ) A weight wiA value viThe total capacity of your knapsack is w.Determine the optimal way to fill the knapsack with a subset of these items to maximize the total value. This means you can takeany portion 0≤ξ≤1 of item i, where xi is the fraction of item i taken. The total weight of the
QuestionYou are given a set of items, where each item i hasA weight wiA value viThe total capacity of your knapsack is wDetermine the optimal way to fill the knapsack with a subset of these items to maximize the total value. This means you can takeany portion of item where xi is the fraction of item i taken. The total weight of the selected items includingfractions must not exceed the knapsack's capacityHint: Use merge sort algorithm.You have been provided with the driver code, with appropriate TODO comments to guide you through the implementation. You have toonly edit merge mergesort and knapsack subroutines in the file studentfile.c You have been provided with the drivercode in the main function in the same file. DO NOT MODIFY ANY LINES OF THE FILE APART FROM WITHIN THE FUNCTION mergemergesort and knapsack else your assignment will not be evaluated. You are free to add other functions if you wish toNote: The example input given here differs from the test cases checked when the code is submitted.code#include#includeDefine a structure for itemstypedef struct int weight; int value; double ratio;Item;Function prototypesvoid mergesortItem items int left, int right;void mergeItem items int left, int mid, int right;double knapsackItem items int n int capacity;Main functionint main int n capacity; User inputs scanfd &n; Item itemsn; for int i ; i n; i scanfd d &itemsivalue, &itemsiweight; itemsiratio doubleitemsivalue itemsiweight; scanfd &capacity; Calculate the maximum value double maxvalue knapsackitems n capacity; printffmaxvalue;- There are 3 steps to solve this one.SolutionStep 1View the full answer
Answer:
Aim: The aim of this program is to solve the Fractional Knapsack Problem using a combination ...
Step 2UnlockStep 3UnlockAnswerUnlock
Not the question you’re looking for?
Post any question and get expert help quickly.