怎么算空间复杂度
我想问下以下代码的空间复杂度怎么算时间复杂度是O(MAX_NUM^2)嘛?
#include <stdio.h>
#define MAX_NUM 100
int main(int argc,char *argv[])
{
unsigned int buf[MAX_NUM];
unsigned int i,j;
for (i=0;i<MAX_NUM;i++)
buf[i] = i;
for (i=2;i<MAX_NUM;i++)
{
if (buf[i] != 0)
{
for (j=i+i;j<MAX_NUM;j+=i)
buf[j] = 0;
}
}
for (i=2;i<MAX_NUM;i++)
{
if (buf[i] != 0)
printf(”%d ”,i);
}
return 0;
}