As integers arrive one by one, build a data structure MRU that holds "the K most recently accessed distinct values" in most-recent-first order. (K = MRU_K = 5) Accessing a value brings it to the very front (index 0). Complete mru_access, and add edge cases to tests.c. (mru_init and mru_dump are provided.) Note: mru_access(m, x) accesses value x. mru_dump(m, out) fills out in most-recent-first order and returns the count. This is the cousin of the LRU cache — an MRU (Most Recently Used) list.
Complete the access handling of a Most Recently Used (MRU) data structure in pure C (C11). As integers arrive one by one, it holds the K most recently accessed distinct values (K=5) in most-recent-first order, and accessing a value brings it to the front. You practice verifying a bounded most-recent list.
A bounded most-recent list (MRU) is a structure common in places like caches. The key points are how a repeated access to the same value is handled, what happens when distinct values fill and overflow the bound, and whether the most-recent-first order holds. Ordinary inputs hide much of it, so the habit of checking edge cases like inputs that exceed the bound and re-accessing the same value matters. This problem deals with the area of maintaining a bounded most-recent list.