Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ToDo - Roadmap Outlook Dashboa Student My Day coderbyte.com / editor / LRU Cache:Java / :candidate#usernqgxh 2 wnz coderbyte Time lefi: 0 hours, 2 6

ToDo -
Roadmap
Outlook
Dashboa
Student
My Day
coderbyte.com/editor/LRU Cache:Java/:candidate#usernqgxh2wnz
coderbyte
Time lefi: 0 hours, 26 mlnutes
medium
LRU Cache
Have the function LRUCache (s traxre) take the array of characters stored in straxr, which will contain characters ranging from A to Z in some arbitrary order, and determine what elements still remain in a virtual cache that can hold up to 5 elements with an LRU cache algorithm implemented. For example: if straxr is [,"B","C","D",'AP,"E','D','Z'l, then the following steps are taken:
(1) A does not exist in the cache, so access it and store it in the cache.
(2) B does not exist in the cache, so access it and store in in the cache as well. So far the cache contains: [A.""B1].
(3) Same goes for C, so the cache is now: .
(4) Same goes for D, so the cache is now: [A',"B","C","D]).
(5) Now A is accessed again, but it exists in the cache already so it is brought to the front: [B',C,C',A].
(6) E does not exist in the cache, so access it and store it in the cache: [','C","D','A","E"'].
(8)Z does not exist in the cache so add in to the front and remove the least recently used element: [",A,"E","D",.
Now the caching steps have been completed and your program should return the order of the cache with the elements joined into a string, separated by a hyphen. Therefore, for the example above your program should return C-A-E-D-Z.
Examples
Input: new String[]{''A'',B,A,C,A,B}
Output: C-A-B
Output: E-D-Q-Z-C
Browse Resourees
powered by Google
Search for any help or documentation you might need for this problem. For example: array indexing, Ruby hash tables, etc.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

=+interactive online components, out-of-home messages, print ads,

Answered: 1 week ago

Question

=+Why does the brand want to advertise?

Answered: 1 week ago

Question

=+12. Did your concept illustrate the brand's personality?

Answered: 1 week ago