Hi all,
I came over an interesting post in stackoverflow
It explains that in Java/C++ processing a sorted array is faster than an unsorted.
Let's say you have an array @a, then.
my $sum;
foreach my $x(@a) {
if($x>128) {
$sum +=$x;
}
}
If @a is sorted, will it be faster than unsorted?
Similary if i have a condition:
fun_a($x) && fun_b($x) &&.....&&fun_z($x)
and fun_z fails consistently, will fun_z be calculated at the beginning?
Thanks,
David
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|