Skip to main content
3 of 5
deleted 120 characters in body
Ahmad
  • 1.9k
  • 3
  • 21
  • 36

Are recursive algorithms a declarative approach to solve the problems?

I have noticed many problems in algorithms textbook are solved by recursion (divide and conquer, backtracking,...)

As I tried to enhance my skills in writing them, I have noticed, I just need to translate a recursive definition of the problem to the code. Then I don't even need to know how it will be executed. I thought recursion may naturally belong to declarative languages or it's just a declarative expression and meant to get this acknowledge by the question.

Actually I am new to functional or declarative programming (I just was studying some about them). Is it a good advice for students to think declarative (the definition rather how) when they want to write a recursive algorithm? Could it be a general rule for any recursive algorithm?

Ahmad
  • 1.9k
  • 3
  • 21
  • 36