تم الحل ✓
categoryهندسة الحاسبات
schoolبكالوريوس
event_available2026-07-15
السؤال
Transcribed Image Text:
Question 4. Consider the problem of storing n books on a
bookshelf, where the length of each shelf is L. The order of
the books is fixed and cannot be rearranged. Therefore, we
can speak of a book b, where 1≤i≤ n, that has a thickness ti
and height h;. Assume there is enough space to store all the
books regardless of the book placement plan. Define the cost
of a book placement plan to be the number of shelves that it
uses.
Suppose all the books have the same height h (i.e. h = h, h;
for all i, j) and the vertical distances between two
neighboring shelves are all greater than h, so any book fits
on any shelf. A greedy algorithm to minimize the cost would
fill the first shelf with as many books as we can until we get
the smallest i such that b, does not fit, and then repeat with
subsequent shelves. Show that the greedy algorithm indeed
minimizes the cost. Analyze the time complexity of the
algorithm. (20')
check_circle الجواب — حل مفصل خطوة بخطوة
hourglass_top
🔒
الحل الكامل متاح للمشتركين
اشترك في أرشيف الأسئلة لعرض هذا الحل وآلاف الحلول المفصلة خطوة بخطوة من معلمين معتمدين.