skip to main | skip to sidebar

Sedikit Ilmu Yang Berguna

  • Entries (RSS)
  • Comments (RSS)
  • Home
  • About Us
  • Archives
  • Contact Us

Tuesday, April 19, 2011

rekursif

Posted by randiadma at 12:00 AM
A.ITERATIVE TO REKURSIVE CONVERSION
   
    Iterative Step:
for(int i=0;i<5;i++)
cout<<“mencoba rekursi\n”;
Rekursive Step:
void coba(int i)
{if(i==5)
{}
else
cout<<“mencoba rekursi\n”;coba i+1;
}
main()
{int i=0;
coba(i);
}

B.REKURSIVE TO ITERATIVE

Rekursive Step:
void coba(int i)
{if(i==5)
{}
else
cout<<“mencoba rekursi\n”;coba i+1;
}
main()
{int i=0;
coba(i);
}
Iterative Step:
for(int i=0;i<5;i++)
cout<<“mencoba rekursi\n”;
C. ANALISIS

For example, the function is called with value i = 0 so for the first we must check is i = 5 {if(i==5) or not, and if its have a same value its will be out.
In reality, i is not same with 0 so, please add i with 1. And the condition now become i = 2.
In next line, we show the value of i. Next, called rekursive function with value i = 2.
That steps is repeating until rekursive function calling with value i = 5.
For now, the if condition is true and that make the function out (return) and continue the command after calling rekursive function with i = 5. Then print out value i.
After print out value i then rekursive function will be out again, and go a head to the command after calling rekursive function where the value before is i = 4. And thats repeating until the value i = 0, thats the first calling rekursive function.
This is the calling rekursif function ilustrated in Indonesia:
Langkah ke :
1. i = 4 ; mencoba rekursi
2. i = 3 ; mencoba rekursi
3. i = 2 ; mencoba rekursi
4. i = 1 ; mencoba rekursi
5.i  = 0 ; mencoba rekursi
Jika di panggil i=5 akan keluar,sebaliknya dengan operasi rekursif ke iteratif
Email This BlogThis! Share to X Share to Facebook

0 comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Sponsored

  • banners
  • banners
  • banners
  • banners

Blog Archive

  • ►  2012 (61)
    • ►  June (2)
    • ►  May (9)
    • ►  April (19)
    • ►  March (27)
    • ►  February (1)
    • ►  January (3)
  • ▼  2011 (44)
    • ►  December (2)
    • ►  November (11)
    • ►  October (1)
    • ►  September (5)
    • ►  May (1)
    • ▼  April (16)
      • bilangan 3 dan 5
      • deret
      • rekursif
      • BBM
      • tugas deret suku
      • alpro3
      • alpro2
      • alpro
      • c++ part 2
      • c++ part 2
      • c++
      • c++
      • c++
      • part 1
      • jeliot 2
      • jeliot
    • ►  March (8)

Followers

Clock Widgets

About Me

My photo
randiadma
Saya Mahasiswa UAD, Jurusan Teknik Informatika,
View my complete profile

My Fuckkn Facebook

Randy Mix Emax

Buat Lencana Anda

Followers

Powered by Blogger.

Blog Archive

  • ►  2012 (61)
    • ►  June (2)
    • ►  May (9)
    • ►  April (19)
    • ►  March (27)
    • ►  February (1)
    • ►  January (3)
  • ▼  2011 (44)
    • ►  December (2)
    • ►  November (11)
    • ►  October (1)
    • ►  September (5)
    • ►  May (1)
    • ▼  April (16)
      • bilangan 3 dan 5
      • deret
      • rekursif
      • BBM
      • tugas deret suku
      • alpro3
      • alpro2
      • alpro
      • c++ part 2
      • c++ part 2
      • c++
      • c++
      • c++
      • part 1
      • jeliot 2
      • jeliot
    • ►  March (8)
 

© 2010 My Web Blog
designed by DT Website Templates | Bloggerized by Agus Ramadhani | Zoomtemplate.com