Asked • 03/13/19

Recursion or Iteration?

Is there a performance hit if we use loop instead of recursion or vice versa in algorithms where both can serve the same purpose? Eg : Check if given string is palindrome.I have seen many programmers using recursion as a means to show off when a simple iteration algorithm can fit the bill.Does the compiler play a vital role in deciding what to use?

1 Expert Answer

By:

Patrick B. answered • 03/13/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.