Selasa, 25 Oktober 2016

Menghitung Worst case, Best case,dan Average case Program Faktorial

program Faktorial
kamus
   n,fak,i : integer
Algoritma
       read(n)
       fak ß 1
       for i ß n downto 1 do
                fak ß fak * i
                write(i)
                if   i = 1
                   then
                            write('')
                   else
                            write('*')
                endif
           endfor

terdalam (write)
TMin   = 2n ≈ n
TMax  = 2n ≈ n

Tavg    = (2n + 2n)/2
            = 2n
            ≈ n

Tidak ada komentar:

Posting Komentar