Talk:Longest common prefix: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎No lists case: new section)
Line 1: Line 1:
Please explain the maths equation for an audience of programmers rather than mathematicians, thanks. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 15:00, 19 March 2015 (UTC)
Please explain the maths equation for an audience of programmers rather than mathematicians, thanks. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 15:00, 19 March 2015 (UTC)


== No lists case ==
== No strings case ==


As I understand it, the example says that given 0 lists, it should return the empty string, i.e. <code>lcp() = ""</code>. Is this necessary? I would argue the answer is undefined in this case, as ''any string'' is vacuously a "common prefix" of 0 strings, and therefore the "longest common prefix" is the longest string, which doesn't exist. --[[User:Spoon!|Spoon!]] ([[User talk:Spoon!|talk]]) 01:32, 21 March 2015 (UTC)
As I understand it, the example says that given 0 strings, it should return the empty string, i.e. <code>lcp() = ""</code>. Is this necessary? I would argue the answer is undefined in this case, as ''any string'' is vacuously a "common prefix" of 0 strings, and therefore the "longest common prefix" is the longest string, which doesn't exist. --[[User:Spoon!|Spoon!]] ([[User talk:Spoon!|talk]]) 01:32, 21 March 2015 (UTC)

Revision as of 01:32, 21 March 2015

Please explain the maths equation for an audience of programmers rather than mathematicians, thanks. --Paddy3118 (talk) 15:00, 19 March 2015 (UTC)

No strings case

As I understand it, the example says that given 0 strings, it should return the empty string, i.e. lcp() = "". Is this necessary? I would argue the answer is undefined in this case, as any string is vacuously a "common prefix" of 0 strings, and therefore the "longest common prefix" is the longest string, which doesn't exist. --Spoon! (talk) 01:32, 21 March 2015 (UTC)