gpt4 book ai didi

recursion - 递归方法会增加圈复杂度吗

转载 作者:行者123 更新时间:2023-12-02 23:29:45 25 4
gpt4 key购买 nike

我目前没有安装任何程序来测量循环代码复杂性。但我想知道递归方法是否会增加复杂性?

例如

// just a simple C# example to recursively find an int[]
// within a pile of string[]
private int[] extractInts(string[] s)
{
foreach (string s1 in s)
{
if (s1.ints.length < 0)
{
extractInts(s1);
}
else
{
return ints;
}
}
}

谢谢。

最佳答案

据我了解,没有。在您的示例中,递归方法只有一条线性独立的路径,因此它不会增加圈复杂度。

关于recursion - 递归方法会增加圈复杂度吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3528491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com