Tarjan: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
(K) |
||
Line 888: | Line 888: | ||
Results in the zero-base scheme: Array{Int64,1}[[2, 1, 0], [6, 5], [4, 3], [7]] |
Results in the zero-base scheme: Array{Int64,1}[[2, 1, 0], [6, 5], [4, 3], [7]] |
||
</pre> |
</pre> |
||
=={{header|K}}== |
|||
Implementation: |
|||
<syntaxhighlight lang=K>F:{u::#g::x |
|||
r::s::!i::0 |
|||
t::+`j`k`o!u#'u,u,0 |
|||
L::{t[x]:i,i,1 |
|||
s,:x |
|||
i::i+1 |
|||
{ $[u=t[`k;y] |
|||
[L[y]; t[`j;x]&:t[`j;y]] |
|||
t[`o;y] |
|||
t[`j;x]&:t[`j;y] |
|||
]}[x;]'g[x] |
|||
$[=/t[`j`k;x] |
|||
[a:*&x=s |
|||
c:a_s |
|||
t[`o;c]:0 |
|||
s::a#s |
|||
r::r,,c] |
|||
]} |
|||
{$[u=t[`k;x]; L[x]; ]}'!#g |
|||
r}</syntaxhighlight> |
|||
Example: |
|||
<syntaxhighlight lang=K>F (1;2;0;1 2 4;3 5;2 6;5;4 6 7) |
|||
(0 1 2 |
|||
5 6 |
|||
3 4 |
|||
,7)</syntaxhighlight> |
|||
tested with ngn/k |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |