This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: calculating the length ??


Hi Anders,

There was a lengthy thread in January in which Jeni and I iterated through possible solutions to
the problem of finding of a maximum element.

What was achieved was an O(N) solution, which worked for an arbitrary node-set with N nodes.
Special attention was also paid to minimise the recursive depth of the solution.
http://sources.redhat.com/ml/xsl-list/2001-01/msg00354.html


Recently I was involved with a similar problem -- find the biggest K elements out of N.

While the obvious approach is to repeat k times the process of finding a single max element
and this has complexity k*N, I used a much faster algorithm (and implemented it
in XSLT), which has complexity of Log2(k)*N. It also uses an implementation of the
binary search algorithm.
http://www.vbxml.com/snippetcentral/main.asp?view=viewsnippet&id=v20010310050532

Hope this helped.

Cheers,
Dimitre Novatchev.

> I hope You can help me solving my problem. 
> 
> <LIST>
> <ELEMENT lenght="2"/>
> <ELEMENT lenght="10"/>
> <ELEMENT lenght="4"/>
> </LIST>
> 
> I would like to know what the max length is for the elements, how can I do
> that ???
> The result should be 10.


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]