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.

^other^ ^rules^

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 1 year ago (7 children)

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.

[–] [email protected] 1 points 1 year ago (5 children)

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.

[–] [email protected] 0 points 1 year ago (4 children)

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).

[–] [email protected] 1 points 1 year ago

I feel like this metaphor is getting out of hand

load more comments (3 replies)
load more comments (3 replies)
load more comments (4 replies)