Wmo | Computer Science homework help

The World Meteorological Organization (WMO) has hired you to write a data structure that stores record temperatures across the globe. Incoming temperature reports have very precise geo-location data (latitude and longitude coordinates). The WMO would like for you to store data in a “grid”, treating any points that round to the same latitude and longitude within one decimal as the same. Note that we are using negative numbers for southern latitudes and western longitudes, so the above coordinates correspond to (36.4° N, 105.0° W). Write a data structure TempMap that keeps track of the hottest and coldest temperatures for each reported coordinate. There is a lot of data coming in, so you need to read and write this information quickly – you should be able to update the record at a (lat, long) pair in O(1). Do not use the built-in set or dictionary types in this assignment. class TempMap Write a class TempMap that keeps track of the maximum and minimum temperature for each reported set of coordinates. Magic Methods init O(1) in O(1) Returns True (False) if the rounded version of a specified coordinate is (is not) in this collection get O(1) Returns a tuple containing the (min, max) temperatures at these coordinates Raise a KeyError if the specified coordinate are not in this collection the input coordinates may or may not be rounded Non-Magic Methods add_report(pos, temp) O(1) pos – an (unrounded) tuple of coordinates temp – the current temperature at those coordinates Updates the maximum or minimum recorded temperature for pos if appropriate remove_pos(pos) O(1) removes the record for the given position from this collection raises a KeyError if pos is not in this collection Special Behavior Memory constraint – you should limit your memory usage to be between 1/2 and 2x the amount necessary to store the number of unique coordinates – that is, you should periodically increase and decrease the amount of memory used as items are added and removed. The starter code includes a function generate_report that returns a randomly generated tuple of (lat, long, temperature). Feel free to use it to help with testing

Leave a Reply

Your email address will not be published. Required fields are marked *