Click here to Skip to main content
15,891,976 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Producer/Consumer Questions Pin
Luc Pattyn26-Apr-07 13:50
sitebuilderLuc Pattyn26-Apr-07 13:50 
GeneralRe: Producer/Consumer Questions Pin
Leslie Sanford29-Apr-07 17:09
Leslie Sanford29-Apr-07 17:09 
QuestionLinked lists vs. Arrays Pin
Leslie Sanford25-Apr-07 9:44
Leslie Sanford25-Apr-07 9:44 
AnswerRe: Linked lists vs. Arrays Pin
Luc Pattyn25-Apr-07 14:55
sitebuilderLuc Pattyn25-Apr-07 14:55 
AnswerRe: Linked lists vs. Arrays Pin
Shog925-Apr-07 14:57
sitebuilderShog925-Apr-07 14:57 
GeneralRe: Linked lists vs. Arrays Pin
Leslie Sanford25-Apr-07 15:04
Leslie Sanford25-Apr-07 15:04 
GeneralRe: Linked lists vs. Arrays Pin
Shog925-Apr-07 15:24
sitebuilderShog925-Apr-07 15:24 
GeneralRe: Linked lists vs. Arrays Pin
Leslie Sanford25-Apr-07 15:38
Leslie Sanford25-Apr-07 15:38 
Shog9 wrote:
A perfect hash would give you O(1) - the hash would be guaranteed to correspond to only one entry in the table. Whether or not a perfect hash is feasible depends a lot on what you're using for keys, as well as how much time is acceptable for calculating the hash.


Understood. But just to be clear, what I meant by not knowing how to access items in a hashtable by index was that I don't know how you could treat a hashtable as an array. Say you're using keys of a certain type. To get the value associated with the a key in a hashtable, you do this:

Value someValue = hashTable[someKey];


However, say we want the 10th item added to the hashtable. I don't know how we do this:

Value someValue = hashTable[9];


We can't treat the index itself as a key because as items are removed or inserted somewhere at the beginning or middle, we'd have to update all of the subsequent indexes; we're back where we started from.

Shog9 wrote:
But i was thinking more along the lines of chained hash tables[^], which are essentially an array of linked lists - this is the technique used by MFC's various CMap classes. Their performance can be very consistent but iteration tends to be rather poor unless table size and hash functions are chosen carefully.


I could see how this would work for simulating an array. Have a linked list with each node containing a linked list. Limit the number of items each list to some arbitrary number like 16. Then if you need to reach the nth item, you can skip over a large number of items at a time. I can see problems with this as items are deleted; you'd wind up with some nodes not having very many items in their list. At any rate, the more I think about this, the more I get the feeling that I'm just reinventing the tree and my brain starts to short circuit.
GeneralRe: Linked lists vs. Arrays Pin
Shog925-Apr-07 16:15
sitebuilderShog925-Apr-07 16:15 
GeneralRe: Linked lists vs. Arrays Pin
cp987625-Apr-07 15:42
cp987625-Apr-07 15:42 
GeneralRe: Linked lists vs. Arrays Pin
Chris-Kaiser26-Apr-07 7:16
Chris-Kaiser26-Apr-07 7:16 
GeneralHybrid List source Pin
Chris-Kaiser26-Apr-07 7:24
Chris-Kaiser26-Apr-07 7:24 
GeneralRe: Hybrid List source Pin
Leslie Sanford26-Apr-07 12:35
Leslie Sanford26-Apr-07 12:35 
GeneralRe: Hybrid List source Pin
Chris-Kaiser27-Apr-07 11:51
Chris-Kaiser27-Apr-07 11:51 
GeneralRe: Linked lists vs. Arrays Pin
Stephen Hewitt26-Apr-07 14:02
Stephen Hewitt26-Apr-07 14:02 
AnswerRe: Linked lists vs. Arrays Pin
Stephen Hewitt25-Apr-07 18:02
Stephen Hewitt25-Apr-07 18:02 
QuestionLine intersection Pin
abalbo24-Apr-07 4:38
abalbo24-Apr-07 4:38 
AnswerRe: Line intersection Pin
Arun.Immanuel24-Apr-07 4:56
Arun.Immanuel24-Apr-07 4:56 
QuestionThreshholding ? Pin
Ray Kinsella24-Apr-07 3:19
Ray Kinsella24-Apr-07 3:19 
AnswerRe: Threshholding ? Pin
David Crow24-Apr-07 3:39
David Crow24-Apr-07 3:39 
QuestionLoop Pin
MoustafaS21-Apr-07 9:21
MoustafaS21-Apr-07 9:21 
GeneralRe: Loop Pin
MoustafaS21-Apr-07 10:27
MoustafaS21-Apr-07 10:27 
AnswerRe: Loop Pin
Frank Kerrigan2-May-07 5:45
Frank Kerrigan2-May-07 5:45 
QuestionImage Recognition Algorithm Pin
softwaremonkey19-Apr-07 5:42
softwaremonkey19-Apr-07 5:42 
AnswerRe: Image Recognition Algorithm Pin
Luc Pattyn19-Apr-07 6:24
sitebuilderLuc Pattyn19-Apr-07 6:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.