while(true)循环的时间复杂度是多少?

时间:2018-08-16 00:34:40

标签: time complexity-theory

我正在使用遗传算法解决最小顶点覆盖问题。

要创建初始种群,其初始解必须涵盖过程中的图G(V,E)。为了创建初始解,将其表示为二进制矢量,其长度等于图形顶点的数量(V)。如果生成的随机数> 0.01,则此向量中每个顶点的值将为1,否则为0。

以下是我的一部分代码:

while (population size != n)//n: number of initial population solutions 
    while(true)
    {
       create initial solution S // as described in advance which it is O(V)
       if (S cover graph G) then // checking solution coverage is O(E), E: number of edges
       {
          add S to the initial population
          increase population size by 1
          exit while loop 
        }
    }

我的问题是:时间复杂度是多少?具体来说,一般情况!知道我们对可以覆盖图G的解性质没有任何想法,只是所有顶点值为1的解矢量覆盖了图100%。

0 个答案:

没有答案
相关问题