Random-access structures in C++?

Is an array, sequential list, and linked list random-access structures in C++?

I know random-access means that you can access the elements stored in the structures randomly (go from 0 to 3 to 5 to 2...) but I'm not sure about these. I don't an array or sequential list is random-access but I think linked lists might be. Am I right? Can you explain why if I'm wrong?

Thanks!

3 Answers

Relevance
  • 9 years ago
    Favorite Answer

    Random access in this case means you can pick where you want to access the data. It's not "random" like rolling the dice or anything.

    An array would be random-access because, if you want the 14th element in the array, you just specify [14] in the array specifier and, "boom" there it is.

    A linked list is not random-access because if you want a given piece of data, you need to traverse the nodes of the list until you get to it. If you want the 14th element you have to start at the first, move to the second, then the third, etc. until you get to the 14th.

  • 9 years ago

    array

    file also can be accessed randomly

  • ?
    Lv 4
    4 years ago

    Why do you call it randList in one section and chunkslist in yet another section? printf %s is finding for a null terminated character string, which potential if chunkslist is a char** that has been good allotted and initialize than **chunkslist factors to a char. you ought to use %c for that, no longer %s

Still have questions? Get your answers by asking now.