看板 Grad-ProbAsk 關於我們 聯絡資訊
Consider the following two programs segments that set a two-dimensional array a as n*n identity matrix: int j,k; int j,k; for(j=0;j<n;j++) for (j=0;j<n;j++) { for(k=0;k<n;k++) { for (k=0;k<n;k++) a[j][k]=0; if(j==k) a[j][j]=1; a[j][k]=1; } else a[j][k]=0; } (a)Give a big-Oh characterization in terms of n, of the running time of these segments. (b)Which program segment is faster if the assignment of a value to an array variable takes about the same amount of time as the comparison of j and k? why? 想請問一下以上a.b兩題,要如何計算呀 我用matrix基本定理計算好像跟原先答案有些出入!! 有人肯提供我詳解嗎!!thanks~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.39.11.21