Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 You are asked to efficiently implement an abstract data type ( ADT ) that keeps records of temperatures in various towns around the
Question
You are asked to efficiently implement an abstract data type ADT that keeps records of
temperatures in various towns around the world at different datestimes This ADT should have
the following public API.
Y
public class GlobalTemps
GlobalTemps create an empty object of the ADT
void setTempString town, store a temperature for the given town
Integer timestamp, Integer tempandtimestamp
Integer getTempString town, return the most recent temperature
Integer ts recorded for a town, with a timestamp
older than or equal to ts
Integer getMaxTemp String town return the highest temperature
recorded for a town
Note that a timestamp is an integer representation of a datetime with the property that more
recent datestimes have chronologically higher timestamp values.
You can assume that no two calls to set Temp will have identical towntimestamp parameters.
The two get methods should return null when the town is not recorded in the data structure,
or the timestamp requested is older than the oldest recorded temperature for that town.
Your implementation can use internally any known ADT, for which you must provide:
e the name of the ADT, as it is known in the literature,
o the signatures of the relevant APt methods only those you use which can but do not
need to employ Java generics,
e the asymptotic worst case running time of these methods, with a justification that
identifies the underlying implementation of the ADT.
Analyse the performance of your GlobalTemps implementation and calculate the worst case
asymptotic running time for each of its methods. In this analysis you should assume that:
o the number of towns stored in the data structure is N
o for each town there are M different temperature measurements
You should calculate running times as functions of both N and M
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started