@Recursion is a process in which a function calls itself as a subroutine. This allows the function to be repeated several times.
@Recursion property
@Tower of Hanoi
Size: 1.38 MB
Language: en
Added: Mar 12, 2020
Slides: 9 pages
Slide Content
Objective of presentation Define recursion and it’s property Example of recursion Tower of Hanoi and it’s algorithm Example of tower of Hanoi.
Recursion Recursion is a process in which a function calls itself as a subroutine. This allows the function to be repeated several times.
R ecursion property Recursive procedure must have the following two properties: There must be certain criteria, called base criteria. Each time the procedure does call itself,it must be closer to the base criteria.
E xample of recursion Factorial function The product of positive integer from 1 to n is called “n factorial”. If N=0 then, When N=1 F N =1 F 1 =1*F 1-1 2) If N>0 then, F 1 =1* F F N =N* F N-1 F 1 =1 When N=0 Similarly,F 2 =2 F = 1 F 3 =6
T ower of Hanoi Tower of Hanoi is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. Following rules: .Only one disk must be moved at a time. No disk may be placed on top of a smaller disk The minimum number of moves required to solve a Tower of Hanoi
A lgorithm General notation Tower(N,BEG,AUX,END) if N>0 then Move ( N-1 ,BEG ,END ,AUX) BEG END TOWER(1,BEG,AUX,END) Move ( N-1 ,AUX ,BEG ,END) Return.