This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
More efficient max() algorithm (Was: Re: Re: Max value from a table )
- To: xsl-list at lists dot mulberrytech dot com
- Subject: More efficient max() algorithm (Was: Re: Re: [xsl] Max value from a table )
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Tue, 23 Oct 2001 21:38:41 -0700 (PDT)
- Reply-To: xsl-list at lists dot mulberrytech dot com
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output indent="yes"/>
>
> <xsl:variable name="max">
> <xsl:for-each select="/table/row/col">
> <xsl:sort select="text()" data-type="number" order="descending"/>
> <xsl:if test="position() = 1">
> <xsl:value-of select="text()"/>
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
This algorithm, as the one currently presented in the XSLT-FAQ, is O(N * Log2(N))
complex.
There exists an O(N) algorithm -- look for it in the Jan/Feb threads of this group
or in the generic templates download at vbxml.com.
This algorithm uses simple recursion and may crash some XSLT processors.
Another O(n) algorithm, which might be the fastest on a parallel processor
environment and which has minimum recursion depth -- this is a Divide and Conquer
algorithm for max().
Cheers,
Dimitre Novatchev.
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list