Question: In this homework, you will implement an iterable class called OrganizedTruck that stores a truck of rotated sorted boxes and provides O(logn) time search operations.

In this homework, you will implement an iterable class called OrganizedTruck that stores a truck of rotated sorted boxes and provides O(logn) time search operations. Here, we assume that the boxes are sorted by their volume and the boxes with the same volume are equal. Also, an OrganizedTruck may contain repeating elements

In this homework, you will implement an iterable class called OrganizedTruck thatstores a truck of rotated sorted boxes and provides O(logn) time searchoperations. Here, we assume that the boxes are sorted by their volumeand the boxes with the same volume are equal. Also, an OrganizedTruck

Organized Truck In this homework, you will implement an iterable class called OrganizedTruck that stores a truck of rotated sorted boxes and provides O (log n) time search operations. Here, we assume that the boxes are sorted by their volume and the boxes with the same volume are equal. Also, an OrganizedTruck may contain repeating elements. Rotated sorted truck We call a Truck rotated sorted if the rotation is applied on a sorted sequence of boxes. For example, the following code shows a rotated sorted truck. Box(2,1,2)] L = [Box (5,1,1), t = Truck (L) Box (3,2,1), Box(1,1,1), Box(2,1,1), Box(1,3,1), The volume of boxes in L are 5, 6, 1, 2, 3, 4 and it is a sorted sequence rotated for 2 steps to the right. A truck can store boxes with the same volume but different dimensions. Here, we consider the boxes with the same volume to be equal. A truck may contain repeating elements. However, all the repeating elements in a truck should be adjacent. For example, the following truck is a valid rotated sorted truck with repetition. L= [Box (4,1,1), Box (1,2,2), Box(1,1,1), Box (2,1,1), Box(1,3,1), t = Truck(L) Box(3,1,1)] The following code shows an invalid rotated sorted truck with repetition, since Box (4,1,1) and Box (1,2,2) are the same but not adjacent. Box (1,1,1), Box(2,1,1), Box(1,3,1), Box(3,1,1), Box (4,1,1)] L-Box (1,2,2), t = Truck(L) Organized truck An OrganizedTruck has the following ADT .init_(self, truck) -receive a rotated sorted truck and store it internally ._iter (self) -return an iterator that iterates over the boxes in sorted order

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!