I’m trying to figure out a way to store my data in an clever way
-
The objects to store contains a regular integer and a pointer. Each integer value is unique and received in a sequential order (the value is increased by one or more for each time). - I want to find an object with a particular integer value as fast as possible. - I don’t know the number of objects at load time, so I cant load all at once and use binary search. I believe using a tree structure is not the most clever idea, since the data is in order from start. Maybe a skip list is the best idea?.
-
The objects to store contains a regular integer and a pointer. Each integer value is unique and received in a sequential order (the value is increased by one or more for each time). - I want to find an object with a particular integer value as fast as possible. - I don’t know the number of objects at load time, so I cant load all at once and use binary search. I believe using a tree structure is not the most clever idea, since the data is in order from start. Maybe a skip list is the best idea?.
How about some associative data structure, like a hash table or a map? You'd get constant lookup time (average) instead of the log n lookup time you'll get with a tree. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
The objects to store contains a regular integer and a pointer. Each integer value is unique and received in a sequential order (the value is increased by one or more for each time). - I want to find an object with a particular integer value as fast as possible. - I don’t know the number of objects at load time, so I cant load all at once and use binary search. I believe using a tree structure is not the most clever idea, since the data is in order from start. Maybe a skip list is the best idea?.
Store where? It seems to me that if the integer ALWAYS increases by exactly one each time, you can use binary search. Just keep redcuing the index into the list by one-half until you home in on the value. I would htink this shoudl work because our data is of constant size and you know the index value is always increasing.