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 [mailto:[EMAIL PROTECTED] On
Behalf Of andrii_olefirenko
Sent: Saturday, February 23, 2008 1:01 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: What is the best way to compare two arrays
element by element ignoring the o



if you are really concerned about performance I would recommend to
hash values added to the array into common hash and then comparing two
arrays would take only O(1) not O(n)

Andrii Olefirenko

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Sergey Kovalyov"
<[EMAIL PROTECTED]> wrote:
>
> What is the best way to compare two arrays element by element
ignoring the
> order? My solution:
> 
> var differs : Boolean =
> (a.length != b.length) ||
> a.some(
> function(item : Object, index : int, array : Array) : Boolean {
> return (b.indexOf(item) == -1);
> });
> 
> May be the better solution exists?
>



 

Reply via email to