Skip to main content

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)
}

Comments

Popular posts from this blog

unix commands