Algorithm 算法练习。选举时间计算

Algorithm 算法练习。选举时间计算,algorithm,time,execution,Algorithm,Time,Execution,我有一个练习: Test (int n) if(n<=81) then return 1 k=1 h=1 while(k<=n) for j=1 to k do c++ k=k+2 return 9*h + Test(n/3) Exercise(int n) c=1 m=n*n while(m>1) do for j=1 to m do c++ m=m/2 if(n>1) the

我有一个练习:

Test (int n)
  if(n<=81) then return 1
  k=1
  h=1
  while(k<=n)
    for j=1 to k do
      c++
    k=k+2
  return 9*h + Test(n/3)
Exercise(int n)
  c=1
  m=n*n
  while(m>1) do
    for j=1 to m do
      c++
    m=m/2
  if(n>1) then Exercise(n/2)

执行时间是在第一,你必须考虑循环。第一个循环将执行
n/2
次,第二个循环执行
k
次。提示: