Comparing strings from the back?

Gelonida N gelonida at gmail.com
Sat Sep 8 11:52:10 EDT 2012


On 09/07/2012 06:06 AM, Steven D'Aprano wrote:
> On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote:
>
>
> Also of some interest is the best case: O(1) for unequal strings (they
> differ at the first character) and O(N) for equal strings.

The worst case is O(N) or N characters
the average case is O(1) or two characters.

For denial of service attacks or systems, that are NEVER allowed to fail 
the worst case is important.

For most other cases the average complexity counts.

However I still wonder for how many applications the complexity of 
string comparisons would be the limiting factor.







More information about the Python-list mailing list