Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Jo has represented each stack of tyres as a stack ADT using the LinkedStack implementation ( see 7 . 1 . 3 ) . Each

Jo has represented each stack of tyres as a stack ADT using the LinkedStack implementation (see 7.1.3). Each element in the stack is an integer representing the tyre diameter in millimetres. The whole shop is represented as a dictionary of stacks, with the stack being the value and the key being one or more uppercase letters which Jo uses to identify the stack.
The following code creates two stacks of tyres (A and B) and adds some sample tyres to them.
tyre_shop = dict()
tyre_shop['STACK_A']= LinkedStack()
tyre_shop['STACK_A'].push(330)
tyre_shop['STACK_A'].push(310)
tyre_shop['STACK_B']= LinkedStack()
tyre_shop['STACK_B'].push(410)
The results of this are illustrated below:image
When a new tyre is received into stock, Jo needs to identify the most suitable of the existing stacks to put it on. Jo does this by applying two rules:
The diameter of the top tyre must be as close as possible to the new tyre without being smaller than the new tyre.
The candidate stack must be as short as possible. Rule 1 takes priority over rule 2.
Example:
Stack C contains 3 tyres, the top one being 200mm.
Stack D contains 2 tyres, the top one being 300mm.
Stack E contains 4 tyres, the top one being 200mm.
Note this example discounts stacks A and B from the prior example.
If the new tyre was 190mm, Jo would choose stack C since:
The top tyre on the stack is the closest size to the new tyre without being smaller than it.
It is shorter than the other potential stack, E.
Stack D is discounted as, although it is shorter than the other stacks, it does not meet the criteria of rule 1.
Note that if stack E were only 3 tyres high, then Jo's method would give both stack C and stack E as options.

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

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions