subject

The cache lists (linked lists): each level within the cache directory, the actual cache is stored as a linked list object. you will use the cachelist() class to implement this linked list. each cache has a maximum size of 200 ( note that this does not mean there can be a maximum of 200 items in the cache. it means that the sum of the sizes of all content objects in a cache cannot exceed 200). do not change this value. there are 5 functions you must implement yourself.

• def put(self, content, evictionpolicy) :

this function puts content into your cache. as explained earlier, caches should make information readily available to a user. accordingly, you should always insert new content at the front of your list so it is easy to obtain. o you should be checking to make sure that your content is not bigger than the maximum size, in that case it should not be inserted. o accordingly, you should also make sure there is enough space remaining in the cache to insert your content. if there is not enough space, you need to evict content currently in the cache. you must keep removing content until there is enough space to insert the new content (so long as the new content is not bigger than the maximum size). there are two ways to do this: lru or mru. ▪ lru: least recently used • remove the content that was last added to the list ▪ mru: most recently used • remove the content that was most recently added to the list o these eviction policies will be specified when the hashtable’s insert function is called. it will be passed as a string parameter ‘lru’ or ‘mru’.

• def lruevict(self)/def mruevict(self) :

as explained previously you will have to implement these specialized removal functions yourself to remove content from the list based on when it was used (in this case added). o this does not need to return a value.

• def find(self) :

this function should be able to find and return a content object from a cache. if it is not found, it should return none.

• def clear(self) :

this function should remove every single item in a cache, and reset the cache’s size and number of items. when all items are removed, it should return a message indicating so. this is shown in the doctests.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:30
Which of the following is not a symptom of chronic fatigue syndrome
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. sean is a computer programmer. he has programmed an application for toddlers that plays nursery rhymes. however, a logic error has occurred in the program. which problem is a likely consequence of the error? a. the program crashes every time the user wants to play the nursery rhymes. b. the program crosses its buffer boundaries and overwrites an adjacent program. c. the program plays a different nursery rhyme than the one the user intended to play. d. the program shows different structures in its programming language code. e. the program introduces new viruses every time the user plays a nursery rhyme.
Answers: 1
question
Computers and Technology, 23.06.2019 15:20
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
You know the right answer?
The cache lists (linked lists): each level within the cache directory, the actual cache is stored a...
Questions
question
Mathematics, 04.02.2021 14:00
question
Mathematics, 04.02.2021 14:00
question
Mathematics, 04.02.2021 14:00
question
Mathematics, 04.02.2021 14:00
question
Mathematics, 04.02.2021 14:00
question
Chemistry, 04.02.2021 14:00
question
Social Studies, 04.02.2021 14:00
Questions on the website: 13722363