Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Book Shelving Problem and Dynamic Programming Solutions - Prof. Samir Khuller, Assignments of Computer Science

A problem statement for the book shelving problem, where given an array of book heights and widths, and a shelf width, the goal is to find the minimum height of the shelf to accommodate all books. The document also includes recurrence relations and dynamic programming solutions for parts (a) and (c) of the problem.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-jhf
koofers-user-jhf šŸ‡ŗšŸ‡ø

5

(1)

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Book Shelving Problem and Dynamic Programming Solutions - Prof. Samir Khuller and more Assignments Computer Science in PDF only on Docsity! Spring 2009 CMSC 451: Homework 6 Samir Khuller Apr 14 (1) We are given a collection of n books, which must be placed in a library book case. Let h[1..n] and w[1..n] be arrays, where h[i] denotes the height of the i-th book and w[i] denotes the width of the i-th book. Assume that these arrays are given by the booksā€™ catalogue numbers (and the books MUST be shelved in this order), and that books are stacked in the usual upright manner (i.e., you CANNOT lay a book on its side). All book cases have width W , but you may have any height you like. The books are placed on shelves in the book case. You may use as many shelves as you like, placed wherever you like (up to the height of the book case), and you may put as many books on each shelf as you like (up to the width of the book case). Assume for simplicity that shelves take up no vertical height. The book-shelverā€™s problem is, given h[1..n], w[1..n], and W , what is the minimum height book case that can shelve all of these books. Below shows an example of a shelving. The height and width of the 6th book are shown to the right. (Notice that there is some unnecessarily wasted height on the third shelf.) h[6] W H w[6] (a) Write down a recurrence for book shelverā€™s problem. (b) Use your recurrence to develop an efficient dynamic programming for solving the book shelverā€™s problem. (c) Analyze the running time of your algorithm. (2) Design an algorithm that runs in time O(nK) that takes as input a set S = {x1, x2, . . . , xn} of integers, and a value K and returns a subset S ā€² of S that adds exactly to K. In other words, if such a subset exists, your algorithm should output it. (3) We are going on a trip along the Appalachian trail. We have a list of all possible campsites that we can camp in along the way (say n). We want to do this trip in exactly K days, stopping Kāˆ’1 nights to camp. Our goal is to plan this trip so that we minimize the maximum amount of walking done in a single day. In other words, if our trip involves 3 days of walking, and we walk 11, 14, 12 miles on each day respectively, 1
Docsity logo



Copyright Ā© 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved