First off, I hope I placed this in the appropriate section. If so...
I've been programming for a while, but this may be a simple question to some (or many).
My Question: If a data structure already exist directly in RAM, then why do we need to spend the processing power to iterate in order to find the right data? (Side Note: pointers still exist in managed languages. They're just handled for you)
My theory is that in order to save memory, the pointer is the only actual data in RAM, so iterating expands the content within the memory address.
Basically if I have a list:
Index 0: list(mylist, 10);
Index 1: list(mylist, 15);
Index 2: list(mylist, 5);
All that would actually be in RAM is:
index 0, index1, index 2
Under my theory, in order to find and access any of it's contents, it has to do some form of parent to child linear search to expand all the data to find '5'? (The parent being the index's pointer to its physical address, and the data structure's value being the child pointer loaded into RAM as it searches):
Index 0: --> GET VALUE '10'; FALSE; Next Address!
Index 1: --> GET VALUE '15'; FALSE; Next Address!
Index 2: --> GET VALUE '5'; TRUE; RETURN Value!
This is all just my theory on it, so that's why I'm asking why iteration exists with data and data structures that are already in RAM, and why I can't just pull a value or any data attribute out of the data structure directly?
It would save so much processing power and development time if I never needed to (or rarely needed to) iterate within RAM.
Thanks for your time, and responses
Edited by Algorithmic_Dream();, 22 June 2014 - 02:01 AM.