Posts

Showing posts from January, 2022

Capacity to ship packages within given days

 Today, let’s focus on a very good application of the famous algorithm binary search. Most of you may be familiar with binary search since it is widely used to implement different algorithms. In fact, I have used it in a few articles before.  Minimum capacity to ship within given days - Problem statement A conveyor belt has packages that must be shipped from one port to another within $d$ days. The $i^{th}$ package on the conveyor belt has a weight of $w[i]$. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship. Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within $d$ days. Also note that we are not allowed to split the items apart and then ship. Minimum capacity to ship within given days - Definition We first need to define the window of possible capacities. Let $w$ be the weight array of items, $d$ be