Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Add Self-Organizing List #24

Open Kalkwst opened 1 year ago

Kalkwst commented 1 year ago

A self-organizing list is a data structure that automatically rearranges its elements based on usage patterns. The idea behind this is those elements that are accessed more frequently are moved closer to the front of the list, making them faster to access in the future. This allows for faster access to the most frequently used elements, improving the overall performance of the list.

From a more technical perspective, a self-organizing list is a variation of a linked list that rearranges its elements based on their access frequency. It uses different algorithms to move the elements that are accessed more frequently towards the front of the list. The most common algorithms used for this purpose are the move-to-front, transpose, and count algorithms. Move-to-front moves the accessed element to the front of the list, transpose moves the accessed element one position forward, and the count keeps track of the access count of each element and moves it to the front of the list based on its access count. These algorithms are used to improve the cache locality, and as a result, the access time for the frequently accessed elements becomes faster. These lists are especially useful in scenarios where the elements' access pattern is not random but follows certain rules or patterns.