r/computerscience • • Jan 12 '26

Help What does random access mean in this context?

"Fixed-length encoding naturally allows for efficient random access to individual data items or records because the position of any item can be calculated directly."

I am learning about computational structure and I fully understand how fixed-length encoding works. But what exactly is random access in this context? Does it have anything to do with RAM or is it something completely different?

8 Upvotes

14 comments sorted by

View all comments

40

u/lfdfq Computer Scientist Jan 12 '26

You're missing the context, so I'll have to take a guess:

When storing a sequence of items, let's say in a file or even other media like a book, then making each record a fixed length means you know exactly where each record begins and ends.

For example, if you're making a book about trains and make it so each train is a whole page, then it's very easy to jump to the 27th train because it'll be on page 27. If each description was a different size, some half a page, some two pages, you'd have to flick through the book to find it. The same goes for a file, if each record is 100 bytes then the 27th one starts at byte 2600 and you can just start reading from there.

That's the essence of random access: you can just go right there, without having to 'search'.

It's not directly related to 'RAM', other than they both have this random access ability.

12

u/tudorb Jan 12 '26

This is an excellent explanation that would even be worthy of ELI5.

6

u/emlun Jan 13 '26

And the term "random access" is shorthand for "performs well if items are accessed in a random order", as opposed to sequential access. This difference comes up both in theory and in practice.

In practical hardware, the difference is most obvious if you compare for example solid state RAM with spinning disk storage: solid state storage can access any data at any time with close to constant latency, while a spinning disk has to physically rotate the right sector to the reader head before data can be read. The spinning disk is also obviously best at reading data in the order it lies on the disk, not in random order. (There are also many other differences between RAM and non-volatile storage, but not that relevant for this topic.)

In computer science, a vector (contiguous array of constant size elements) supports efficient random access, while a linked list (node object storing value and address of next node) does not since you have to traverse the list one link at a time instead of jumping directly to the index you need.

1

u/InformalTown3679 Jan 13 '26

Perfect visualization