Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you said the worst scenario is to have the L3 (or L2) with all smaller numbers than L1, because the IF clause will fail and it will perform elif section computing more comparations.</p> <p>Inside the first IF (and assuming we will count as an individual comparation each checking of boolean values, like done1, done2, etc.) and having into account that logical expressions ussually are computed in a lazy way, then the worst case is to never reach done1 = true before the others (that is guaranteed as L1 has bigger values than L2 and L3), done2 neither reach true (can be guaranteed having bigger values in L2 than in L3) so the L1[i1] &lt; L2[i2] is computed in every steps.</p> <p>When L3 is finished, and each cycle enters in the IF section and only 4 comparations are performed because done3 is true, and thanks to the lazyness the last comparation is not computed. The same applies when entering the elif section only 2 comparations are performed.</p> <p>When L2 is finished, only 3 comparations are perfomed in the IF clause (as done2 and done3 are true)</p> <p>So, having this configuration (L1 >> L2 >> L3) this algorithm will perform:</p> <p>Len(L3) * (3 (the while clause) + 5 (the IF clause) + 3 (the elif section) + 1 (the done3 calulation)) + Len(L2) * (3 (the while clause) + 4 (the IF clause) + 2 (the elif section) + 1 (the done2 calulation)) + Len(L1) * (3 (the while clause) + 3 (the IF clause) + 1 (the done1 calulation)) </p> <p>so the final count is</p> <p>Len(L3) * 12 + Len(L2) * 10 + Len(L1) * 7</p> <p>The computational Order is the same in any case of ordering of the 3 arrays, the Order is Len(3) + Len(2) + Len(1)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload