Posts

Showing posts from August 19, 2013

recursive fibonacci

a<- -1
b<- -1
c<- -0


fib(a,b)
{
c=a+b
if(c<=n)
{print c
fib(b.c)
}
}

towers of hanoi

Towers Of  Hanoi

// to move all disks from peg 1 to peg 3
// you just have to move n-1 disks to peg2
// and then nth disk to peg 3
// and then n-1 disks to peg 3




towers(ndisks,source,temp,destination,)
if(ndisks <>0)
{
towers(ndisks-1,source, destination,temp)
move  disk from source to destination
towers(ndisks-1,temp,source, destination)
}