Tag Archives: Recursion

Recursion

What is Recursion? The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called as recursive function. Using recursive algorithm, certain problems can be solved quite easily. Examples of such problems are Towers of Hanoi (TOH), Inorder/Preorder/Postorder Tree Traversals, DFS of Graph, etc. What is base… Read More »

Program for Chocolate and Wrapper Puzzle

Given following three values, the task is to find the total number of maximum chocolates you can eat. money : Money you have to buy chocolates price : Price of a chocolate wrap : Number of wrappers to be returned for getting one extra chocolate. It may be assumed that all given values are positive… Read More »

String with additive sequence

Given a string, the task is to find whether it contains an additive sequence or not. A string contains an additive sequence if its digits can make a sequence of numbers in which every number is addition of previous two numbers. A valid string should contain at least three digit to make one additive sequence.… Read More »