{"id":160357,"date":"2023-09-26T13:56:21","date_gmt":"2023-09-26T08:26:21","guid":{"rendered":"https:\/\/www.gkseries.com\/blog\/?p=160357"},"modified":"2023-09-26T13:56:22","modified_gmt":"2023-09-26T08:26:22","slug":"consider-the-weights-and-values-of-items-listed-below","status":"publish","type":"post","link":"https:\/\/www.gkseries.com\/blog\/consider-the-weights-and-values-of-items-listed-below\/","title":{"rendered":"Consider the weights and values of items listed below"},"content":{"rendered":"\n<p>Q. Consider the weights and values of items listed below. Note that there is only one unit of each item.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Item number<\/strong><\/td><td><strong>Weight<\/strong> <strong>(in Kgs)<\/strong><\/td><td><strong>Value<\/strong> <strong>(in Rupees)<\/strong><\/td><\/tr><tr><td>1<\/td><td>10<\/td><td>60<\/td><\/tr><tr><td>2<\/td><td>7<\/td><td>28<\/td><\/tr><tr><td>3<\/td><td>4<\/td><td>20<\/td><\/tr><tr><td>4<\/td><td>2<\/td><td>24<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by \ud835\udc49opt. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by \ud835\udc49greedy.<\/p>\n\n\n\n<p>The value of \ud835\udc49opt \u2212 \ud835\udc49greedy is___________<\/p>\n\n\n\n<p>Ans: 16<\/p>\n\n\n\n<p>Sol:<\/p>\n\n\n\n<p>First we will pick item_4 (Value weight ratio is highest). Second highest is item_1, but cannot be picked because of its weight. Now item_3 shall be picked. item_2 cannot be included because of its weight. Therefore, overall profit by V<sub>greedy<\/sub>&nbsp;= 20+24 = 44 Hence,&nbsp;<strong>V<sub>opt<\/sub>&nbsp;\u2013 V<sub>greedy<\/sub>&nbsp;= 60-44 = 16&nbsp;<\/strong>So, answer is 16.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q. Consider the weights and values of items listed below. Note that there is only one unit of each item. Item number Weight (in Kgs) Value (in Rupees) 1 10 60 2 7 28 3 4 20 4 2 24 The task is to pick a subset of these items such that their total weight [&hellip;]<\/p>\n","protected":false},"author":419,"featured_media":160358,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5141],"tags":[5140],"class_list":["post-160357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gate","tag-gate-questions"],"_links":{"self":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/160357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/users\/419"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/comments?post=160357"}],"version-history":[{"count":1,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/160357\/revisions"}],"predecessor-version":[{"id":160359,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/160357\/revisions\/160359"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/media\/160358"}],"wp:attachment":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/media?parent=160357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/categories?post=160357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/tags?post=160357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}