this post was submitted on 19 Oct 2023
0 points (NaN% liked)
196
16459 readers
33 users here now
Be sure to follow the rule before you head out.
Rule: You must post before you leave.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Ok, I didn't understand roughly half of your comment because I don't actually know how cache works in practice
BUT
a messy pile of clothes represents a stack, doesn't it? And a stack makes a horrible cache because unlike a simple array you don't have fast random access. You'd have to dig through the entire pile of clothes to get to the bottom which takes a lot of time.
Not necessarily. If you know that your pants are at the bottom then you can just plunge your hand into the pile and grab them without any searching.
Thay depends on the size of the pile, there could be a lot of weight and instability above the pants and you'll have to pull them out à la Jenga or carefully rearrange the stack.
Since the amount of rearranging increases for larger n (imagine a pile reaching the ceiling), searching is in ω(1).
I feel like this metaphor is getting out of hand