title: How to think in recursive way?
body: <p>In order to understand the advanced algorithm concepts like greedy methods and dynamic programming, one first need to be well versed in recursion.</p>
  
  <p>I am relatively new to recursion. Whenever a question is asked, the first  things that pops up in mind are solutions using iterations. Even though I know what recursive methods means and how it works, it is very difficult to think in a recursive way.</p>
  
  <p>Please help out by answering the below questions:</p>
  
  <p>1) Can any iterative method be replaced by recursion and vice versa?</p>
  
  <p>For example, how to print elements in an array of size n recursively?</p>
  
  <pre><code>for i 0 to n
   Print a[i]
  </code></pre>
  
  <p>2) How to solve a problem recursively? What are the steps? Is there any tips to identify that a problems can be solved recursively?</p>
  
  <p>For ex: If am asked to print out all the sub strings of a string</p>
  
  <pre><code>INPUT: CAT
  OUTPUT: CAT,CA,A,AT,T
  </code></pre>
  
  <p>I can come up with an iterative way fast.Using two loops can solve the problem.</p>
  
  <p>But recursively how to solve it.How to identify that a problems can be solved recursively.</p>
  
  <p>If answer to my first question is yes, using two recursions instead of iteration can be solution to my problem?</p>
  
  <p>3) Can anyone suggest me some materials/resources to understand the concept of  recursion thoroughly?</p>