RE: [flexcoders] Re: What is the best way to compare two arrays element by element ignoring the o

2008-02-24 Thread Gordon Smith
But MD5 is order-dependent, isn't it? Otherwise, MD5 would say that documents containing "hello, world" and "world, hello" are the same. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of andrii_olefirenko Sent: Sunday, February 24,

RE: [flexcoders] Re: What is the best way to compare two arrays element by element ignoring the o

2008-02-24 Thread Gordon Smith
I agree that it is O(1) in the sense that you describe, because the O(n) work has been amortized to be imperceptible. Do you actually know of a good hash function for this case? - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of a

RE: [flexcoders] Re: What is the best way to compare two arrays element by element ignoring the o

2008-02-24 Thread Maciek
True. However, andrii's solution does amortize the cost of the comparison across all array modifications, so you don't incur it all at once when doing the comparison. Depending on the actual requirements of the situation (and assuming you control array modifications, and are not just trying to comp

RE: [flexcoders] Re: What is the best way to compare two arrays element by element ignoring the o

2008-02-24 Thread Gordon Smith
> Of course, modifying an array would become more expensive operation, but it's still O(1) operation The overhead when modifying each element is O(1), so the total overhead you've incurred is O(n). Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.

Re: [flexcoders] Re: What is the best way to compare two arrays element by element ignoring the o

2008-02-24 Thread Eric Cancil
A more specific use case may result in a more elegant solution On Sun, Feb 24, 2008 at 10:18 AM, andrii_olefirenko <[EMAIL PROTECTED]> wrote: > The trick is to keep hash value of all elements of the array. > Prerequisites are following: > 1. Hash function H(index, object) should return unique v

RE: [flexcoders] Re: What is the best way to compare two arrays element by element ignoring the o

2008-02-23 Thread Gordon Smith
Can you give more detail? I don't believe there is any O(1) algorithm for this. O(1) means that comparing two 100,000-element arrays would take the same time as comparing two 100-element arrays. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [