English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

count =0;
for (i=1; i<5; i++)
for (j=1;j<=3; j++)

pls explain ur logic

2007-10-07 10:52:52 · 2 answers · asked by iwonder 2 in Computers & Internet Programming & Design

2 answers

your missing part of the program .

i, i<5 , i++ will execute 4 times
j, j<=3, j++ will execute 3 times
anything inside those if nested will happen 12 times
for each i , j loop will happen

2007-10-07 11:12:26 · answer #1 · answered by mark 6 · 0 0

5 * 3 = 15; and the logic is the simplest form of running time analyzing. The two dimensions of count gives the total running time.

But the answer could be O(1) for they are constant running time

2007-10-07 18:10:19 · answer #2 · answered by Andy T 7 · 0 0

fedest.com, questions and answers