Recursion, tail optimization and memoization are important piece of Functional programming. Before jumping into solving complex solutions, I slip on basic structure of recursion lot of times. What is base case and what is recursive step? When I ask most recursive person at home, got the answer as "until I need a charge". Seriously??? I don't know what algorithm it is!!???. It moves all around without any pattern until completely got drained. ☺ May be it is the algorithm... So finding the base case says when to stop. Another programming example: We are given a denomination of coins/ currency notes and amount of value. We need to identify the minimum number of coins/ currency notes required for calculating that amount. For the amount $3.15, we need to pick up 12 quarters, 1 dime and 1 nickel. So total number of coins is 14 coins. The base case here -> if total of value is equal to the amount required. The recursive step -> pick a higher denomination available to re...
Choo choo... running behind friends on the street was fun. When I wanted to play the game with kids, they enjoyed it too. Adult next to us looking at weird. No one plays such games on street now a days. But try with your kids and neighboring kids and share how it energizes. We were 5 initially formed the chain. I was the Engine for first few games. I stood in the front and wait for the coaches to join. Sai krishna (my son) follows me every time, happily catches my shirt and said "I am behind you. Hey Engine, start start. Choo choo....". "Hey train wait...." - it was my daughter Danya sri catches Sai krishna shirt and formed next coach. We were riding on the street and all eyes on us. There comes our neighboring kid Sakthi. She follows Danya and now the train is little bigger. We were running on the street happily. Then to make some fun in the middle, Engine started going fast and Danya missed to pick it up immediately. "Hey Engine, wait......
Comments
Post a Comment