Question

Find the optimal solution to the fractional Knapsack problem using Greedy technique: 
 Number of objects n: 6
Maximum Weight M = 25
Value of each item:
(

07 Aug 2023
Answer :
Word Count : 1019

To find the optimal solution to the fractional Knapsack problem using a Greedy technique, we need to consider the value-to-weight ratio of each item and select items greedily based on this ratio. The goal is to maximize the total value while not exceeding the maximum weight capacity of the knapsack.

Let's consider the given problem:

Number of objects n: 6
Maximum Weight M = 25
Value of each item and its weight:

Item 1: Value = 10, Weight = 5
Item 2: Value = 5, Weight = 3
Item 3: Value = 15, Weight = 10
Item 4: Value = 7, Weight = 7
Item 5: Value = 6, Weight = 4
Item 6: Value = 18, Weight = 12

To solve the fractional Knapsack problem using a Greedy technique, we will follow these steps:

  1. Calculate the value-to-weight ratio for each item:
    Item 1: Ratio = Value/Weight = 10/5 = 2
    Item 2: Ratio = Value/Weight = 5/3 ≈ 1.67
    Item 3: Ratio = Value/Weight = 15/10 = 1.5
    Item 4: Ratio = Value/Weight = 7/7 = 1
    Item 5: Ratio = Value/Weight = 6/4 = 1.5
    Item 6: Ratio = Value/Weight = 18/12 = 1.5

  2. Sort the items in descending order based on their value-to-weight ratios:
    ____ _________ _______ ______ ___.
    ____ ________ _________ __________ ___ _________ _________ _____ ____ ______ _______ _________.
    _________ ________ ____ ___ ________ ___ _________.
    _____ _________ ____ ____ _________.
    ____ ___ ___ _____ ______.
    ___ _______ ________ ______ _________ __________ __________ _________ __________.
    ___ ______ _____ _____ ___ ________ ____ __________ _____.
    ______ ____ ________ _________ _________ ___ ________ _________ _________ ______ __________ __________.
    ___ __________ _______ ____ ____ ___ _____ ____ ___ ______.
    ______ _______ __________ _____ ________ __________ ______.
    ____ ___ __________ _______ ___ __________.
    _______ ______ __________ ________ ______ _____ ____ ________ ___ _______.
    ___ ______ ______ _______ ________ ____ ________ ______ __________ ______ _________.
    __________ ____ _____ ______ _____ __________ ________ ______ ________ _____ ___.
    _______ ____ __________ ____ ___ ______ _______ __________ _____ _________ ______.
    ________ _________ _______ _____ _________ ____ _________ _____ ____ ______ ______ ____.
    ____ ________ ________ ____ _________ ____ ______ __________ ______.
    ____ _____ ____ _______ __________ __________ ____.
    ________ ________ _________ ___ ____ ___ ____.
    ____ ______ __________ _________ ____ _____ ______ ____ _____.
    __________ __________ ____ ________ ________ ______ _____ ___.
    ________ _____ _______ _____ __________ ________ ___ _______ _____ __________.
    _________ ______ _____ ___ ______.
    ______ _______ ___ ______ ____ _________ _________ __________.
    _______ ________ ____ _________ _______ ___ ___ ______ ____ ________.
    ______ ____ ______ __________ _______ ___ ________.
    __________ _____ ___ ___ ___.
    __________ ________ ___ ________ ________ ________ ____ _______ ________ _________.
    ________ _________ __________ __________ _____ _________ ________.
    ______ ___ _______ ____ _________ _______ ______ __________ _________ __________ ______.
    _________ ___ ___ _______ ______ ________.
    __________ _____ ____ _________ ________ _______.
    ____ _________ ___ ______ ____.
    ___ _____ __________ ________ _________ ____.
    __________ ____ ____ __________ ______ ______ ____ _______ _____ ___.
    __________ _______ _______ __________ ________ ___.
    ________ _____ ___ _________ _______.
    _________ _________ _______ ________ __________ _______ _______ _______ ____ _________.
    _______ ____ _________ ______ _____ __________ _________.
    _____ ____ _______ ____ ________.
    ________ ______ ___ ___ _________ ________ ____ _________ __________ __________ _________.
    _____ ______ _________ _____ _______.
    _____ ____ ______ __________ ____ ______ ____ ______ _______.
    _______ __________ ________ __________ __________ ______.
    ______ ___ ___ ___ __________.
    ______ __________ _______ _________ __________ ___ ______ ________ _____ ____ ________.
    _________ _________ _______ ______ ___ ________ _______ ___.
    ____ __________ _________ __________ _________ ______ _______.
    __________ ___ ________ _____ ______ __________ _______ _______.
    ____ ___ _________ ______ _____ _________ ________ __________.
    _____ __________ __________ _________ _________.
    _________ __________ ______ _________ _______ _______ __________ ____.
    _______ ______ ______ __________ ____.
    ________ ____ ____ ______ _________.
    _________ ___ _______ ______ _____ ___ ______.
    _______ ___ ______ ___ ___ ________ __________ __________ ___ ____.
    ___ ___ ___ _______ ________.
    _______ _____ _____ ___ _______.
    ______ ___ _______ ___ ____ ______ __________ ___ ____.
    ______ _____ __________ _________ __________.
    _______ ______ ____ _____ _________ ___ ________ _______.
    __________ ___ ___ _____ __________ __________ ____ _________ ________ ________.
    ______ ___ ________ ________ ________ _________ ______ ____ ___ _________ _____.
    ____ ____ _________ _____ __________ ______ ___ _________ ___ __________.
    _______ ____ ________ ______ ____ _________ __________ ____ ____ ____ __________ ________.
    __________ _______ _____ ___ ______ ___ __________ _____.
    ____ ___ _________ ________ _________ ________ _________ ____ _____ ____.
    ______ _________ ____ ___ __________.
    _____ __________ __________ __________ ______.
    _____ _________ __________ ______ ______ ________ __________ _____ _______ __________ ____ __________.
    _________ ________ ___ _________ ________.
    _______ ____ ______ ___ __________.
    _____ _______ ____ ___ _______ _____ ____ _______ ________ _______.
    ______ ______ _______ __________ _____.
    ______ __________ ______ __________ _________ ________ _________.
    ____ _______ _____ _________ _____ ______ ____.
    ____ _____ __________ ____ _______ _____ _________ ______.
    ___ _______ _________ _________ _______ ______ _____ ________.
    _________ _________ _____ _______ __________ ______ ______.
    _______ _______ ________ ________ _______ _____ _______ __________ ___ _________ _______.
    ____ ____ _____ ___ _________ ________ ______ _____ ______ _________.
    ____ ________ _________ _________ ___ _______ ____ ___ ___.
    ________ _________ ___ ___ ___ ___ _________ _________.
    __________ _____ _____ __________ ________ ________ ____ _________ ______ ____.
    ____ _____ __________ ________ ___.
    ________ _____ ____ _______ ________ _____ _______.
    __________ ______ __________ _________ _________ ____ _______.
    _________ _______ ___ ____ ________ _______ __________ _________ _______ __________.
    __________ ________ _____ ________ ___.
    ________ __________ _____ _________ ____ ____ ______ _____ ___ __________ ________ ___.
    ______ _____ _______ ______ ____ _____ ____.
    _______ ________ ___ _______ ________ ___ __________.
    ______ ________ ____ ___ ____ _______ _______ _____.
    __________ __________ _____ ________ _________ ____ ______ _____ ___ _______ _________.
    ______ __________ __________ ________ ________.
    ______ ____ _______ _______ _______ ____ ____ ______ ____ ________.
    _______ ________ _____ ___ _________ ________ _________ _____ ____ ________.
    __________ __________ _______ ________ _____ _________ ____ _____ ________.
    _________ ________ ____ ________ ________.
    _____ ___ ______ __________ ___ ____ _____ _______.
    _______ __________ _____ _____ __________.

    IGNOU ACADEMY
    Your IGNOU journey, made easier.
    • Solved Assignments
    • Study Notes
    • Guess Papers
    • Question Papers
    Skip in 10
'; fetch( "query.php?type=1&method=0&lr=0&app=401&mycartproduct=1", { method: "GET", cache: "no-store" } ) .then(function(response) { if (!response.ok) { throw new Error( "HTTP " + response.status ); } return response.text(); }) .then(function(html) { loader.innerHTML = html; /* Your existing function, if available. */ if (typeof updateTotals === "function") { updateTotals(); } else { calculateCartTotal(); } }) .catch(function(error) { console.error( "Cart loading error:", error ); loader.innerHTML = '
Unable to load cart.
'; });}/* ========================================================= CALCULATE TOTAL========================================================= */function calculateCartTotal() { let subtotal = 0; /* Looks for .item-price inside AJAX products. Examples accepted: ₹200 ₹200.00 Rs 200 Rs. 200 200 200.00 */ const prices = document.querySelectorAll( '#loadmycart .item-price' ); prices.forEach(function(element) { let text = element.textContent || ''; text = text .replace(/₹/g, '') .replace(/Rs\.?/gi, '') .replace(/,/g, '') .trim(); let value = parseFloat(text); if (!isNaN(value)) { subtotal += value; } }); updateCartDisplay(subtotal);}/* ========================================================= UPDATE TOTAL DISPLAY========================================================= */function updateCartDisplay(total) { const subtotalElement = document.getElementById('subtotal'); const totalElement = document.getElementById('total'); const checkoutButton = document.getElementById('checkoutButton'); const noItems = document.getElementById('noitems'); const amount = Number(total) || 0; if (subtotalElement) { subtotalElement.textContent = '₹' + amount.toFixed(2); } if (totalElement) { totalElement.textContent = '₹' + amount.toFixed(2); } /* EMPTY CART */ if (amount
Top