private void listAll( int depth )
{
printName( depth ); // Print the name of the object
if( isDirectory( ) )
for each file c in this directory (for each child)
c.listAll( depth + 1 );
}
漸化式を使用して実行時間を誘導しようとしています
正しい実行時間はO(N)です
私の分析では、O(N ^ 2)になることが示されています
これが私の誘導
1です。T(0)=(1行目)O(1)+(2行目)O(1)+(私たちが想定する子の数はNです)N *(T(1)
2. T(0 )=(1行目)O(1)+(2行目)O(1)+ N *(O(1)+ O(1)+ N *(T(2))
3この誘導が続くと、時間はある種のO(N ^ 2)になります
私の分析の問題は何ですか?