Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago