Can you get them in order?  If the arrays are in alpha order for example
you can just go down both lists together ONCE ( O(n) I think ).  I think it
would be in your best interest to sort them first if you have to.  Any
ordering would do, as long as both lists are in the exact same order:

list1 = a b d e f h i
list2 = a c d e h i k

So to do this you would:
a = a - add a to is-there list, increment both lists
b < c - add b to not in L2 list, increment list1
d > c - add c to not in L1 list, increment list2
d = d - add d to is-there list, increment both lists

Use java.lang.String.CompareTo(String) to do these comparisons.
http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html#compareTo(java.lang.String)
--Angus

"Nimmons, Buster" wrote:
>
> I have two arrays each having around 3000 elements. One array is a list of
> file names from a database and the other is a list of files on a file
> server. I would like to compare the two arrays and  end up with two arrays
> showing what was in each array that was not in the other array. I am looking
> for the most efficient way to do this since these arrays could grow to be
> anywhere from 20,000 to 50,000 in size in the future.
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to