subject

For this next exercise you will re-implemet the binary search tree so that it can be used as a mapping structure. The Node class will be updated so as to hold separate key and value attributes (instead of a single value, as it currently does), and instead of the add method, you should implement the __getitem__ and __setitem__ methods in order to associate keys and values. __delitem__, __contains__, and __iter__ will also need to be updated, to perform key-based removal, search, and iteration. Finally, the keys, values, and items methods will return iterators that allow the keys, values, and key/value tuples of the tree (all sorted in order of their associated keys) to be traversed. If __setitem__ is called with an existing key, the method will simply locate the associated node and update its value with the newly provided value (as you would expect a mapping structure to do). If either __getitem__ or __delitem__ are called with a key that does not exist in the tree, a KeyError should be raised.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:00
Which type of tab stop is most for weights and measurements?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
question
Computers and Technology, 24.06.2019 22:50
Which of these might be an example of an advertiser's target group? a.people who have no access to media b.people the advertisers know nothing about c. people who watch a variety of tv shows d. people who live in the same region of the country
Answers: 2
question
Computers and Technology, 25.06.2019 06:30
How can u permanently delete a picture from your camera ?
Answers: 1
You know the right answer?
For this next exercise you will re-implemet the binary search tree so that it can be used as a mappi...
Questions
question
Mathematics, 09.06.2021 23:20
question
Advanced Placement (AP), 09.06.2021 23:20
question
Mathematics, 09.06.2021 23:20
question
Mathematics, 09.06.2021 23:20
question
Chemistry, 09.06.2021 23:20
question
Mathematics, 09.06.2021 23:20
question
Mathematics, 09.06.2021 23:20
Questions on the website: 13722362