Parag Kalra wrote:
> Hello All,
> 
> I have 2 arrays. I have written a script that searches each and every value
> of first array in the second array. Each & every value of Source Array
> should occur only once in the target array but it can occur anywhere.
> 
> If any of the source value doesn't occur or occur multiple times then the
> script reports to the user.
> 
> This script is working fine for small arrays.
> 
> But I tried executing the script for 2 arrays each of which containing
> around 7,00,0000 elements and it is taking very long time.
> I am using nested 'for' loops to make this search. How can I optimize it
> further to search source array in target array.
> 
> Cheers,
> Parag
> 

Sort both arrays.  For each item in the first array, step through the
second until it is found, you encounter a value greater than it, or you
reach the end of the array.


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to