I knew I was missing something....thanks for the correction and pointer...learn something new every day.
Michael D. Black Senior Scientist Advanced Analytics Directorate Advanced GEOINT Solutions Operating Unit Northrop Grumman Information Systems ________________________________________ From: [email protected] [[email protected]] on behalf of Igor Tandetnik [[email protected]] Sent: Tuesday, October 16, 2012 8:54 AM To: [email protected] Subject: EXT :Re: [sqlite] 5. Re: Sqlite, Is it possible to calculate the length of the longest increasing subsequence using an UDF Black, Michael (IS) <[email protected]> wrote: > Pseudo-code: > > lastchar=''; > For (char c in array) > if (lastchar = '' || c = lastchar+1) > curseq.push(c); > else > curseq.clear(); > curseq..push(c); > end The longest increasing subsequence doesn't need to be contiguous. Nor does the difference between two neighboring elements have to be exactly one - it just have to be a positive number. At least as defined at http://en.wikipedia.org/wiki/Longest_increasing_subsequence E.g. for a sequence of (1, 100, 2, 4) your algorithm finds (1), while the correct answer is (1, 2, 4). -- Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

