Answered step by step
Verified Expert Solution
Question
1 Approved Answer
code in python i For this task, you may assume that all Double Key Table and all Infinite Hash Table methods are O(1), even if
code in python
i For this task, you may assume that all Double Key Table and all Infinite Hash Table methods are O(1), even if they obviously are not. Also note you're welcome to edit and add additional functionality to mountain.py In this task, you'll be working on: mountain_organiser.py As you embark on your Mountain Climbing journey, you find that as time passes, the number of mountains you can climb increases. For the first week, maybe you can only do low-altitude, non-steep mountains, and as time goes on, you can climb more and more difficult mountains. As you climb more and more mountains, you'd like to know the rank of each mountain, if all the mountains you've seen are ranked by their difficulty increasing. In cases where the difficulty is the same, you should order them by name lexicographically increasing (you can assume this is unique) To achieve this, we'd like you to implement the MountainOrganiser class (in mountain_organiser.py), which requires 3 methods: __init__ Initialisation add_mountains (self, mountains: list [Mountain]) -> None: Adds a list of mountains to the organiser cur_position(self, mountain: Mountain) -> int : Finds the rank of the provided mountain given all mountains included so far. See below for an example. Raises KeyError if this mountain hasn't been added yet. i Complexity Requirement add_mountains should have complexity at most O(M log(M) + N), where M is the length of the input list, and N is the total number of mountains included so far. cur_position should have complexity at most O(log(N)), where N is the total number of mountains included so far. Consider the following example:
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