On 10/12/2012 11:23 AM, Frank Chang wrote:
With the latest version of Sqlite, Is it possible to calculate the length
of the longest increasing subsequence, also referred to as sortation
percent, using a sqlite UDF, user defined function? Thank you.
An algorithm described at
http://en.wikipedia.org/wiki/Longest_increasing_subsequence#Efficient_algorithms
should be possible to implement in the form of a user-defined aggregate
function, if that's what you are asking.
The algorithm is O(n) space - that is, it needs to store substantial
portions of the sequence (the whole sequence, in the worst case). In
light of this, I don't quite see what you expect to gain from turning it
into a UDF, as opposed to simply loading the sequence from the database
into memory with a vanilla SELECT statement, and working on it in your
application code.
What's the ultimate goal of the exercise, if you don't mind me asking?
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users