forward-iteration vs reverse-iteration

Tech-Archive recommends: Speed Up your PC by fixing your registry



Is there a performance difference between forward iteration and reverse iteration through a List<string> ?

for ( i = 0; i < myList.Count; i++ )
{
// do work, such as forward iterate through a subset of myList ...
}

vs

for ( j = myList.Count - 1 ; j >= 0; j-- )
{
// do work, such as reverse iterate through a subset of myList ...
}


In other words, is there a performance advantage to pre-sorting a list so that forward iteration may be used in implementing an algorithm ?

.



Relevant Pages

  • Short koan-like code snippets (was: coerce for arbitrary types)
    ... (defun bfs6 (test children pending) ... The algorithm seems to be a tail-recursive expression of what ... I don't like using tail recursion to emulate iteration, ...
    (comp.lang.lisp)
  • Iterative subspace decomposition
    ... Subspace Tracking," IEEE Transactions on Signal Processing, vol. 43, ... the PASTd algorithm does not produce orthogonal ... it is not producing the eigendecomposition I ...
    (sci.math.num-analysis)
  • Re: OO Style with Ada Containers
    ... The most important part of STL is the notion of range-based iteration. ... Every single algorithm that iterates over something gets a pair of ... But there's nothing that precludes that in Ada: ... procedure Generic_Algorithm (First, Back: Cursor); ...
    (comp.lang.ada)
  • Re: rapidly converging rational sqrt
    ... Note that after iteration 6 we have ... > more than 100 significant digits. ... I don't wish to denigrate your algorithm unduly, but square root algorithms ...
    (sci.math.research)
  • Re: Encrypt with RijndaelManaged and decrypt with OpenSSL
    ... I forgot to add that yes this also produces the exact aes key ... you need to invoke the algorithm iteration 3 times to build ... that openssl enc does not provide an option to ...
    (microsoft.public.dotnet.security)