Skip to main content
1 of 5
Ahmad
  • 1.9k
  • 3
  • 21
  • 36

Are recursive algorithms a declarative approach to 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 am an instructor in a university. Many students who get used to imperative style of programming have problem in understanding recursion. Now I think a declarative approach works good.

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 when they want to write a recursive problem? Could it be a general rule at least for major problems?

And what is that best declarative way to approach problems? (I mean focus on definition rather than procedure?)

Ahmad
  • 1.9k
  • 3
  • 21
  • 36