Python Forum
Combine Two Recursive Functions To Create One Recursive Selection Sort Function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combine Two Recursive Functions To Create One Recursive Selection Sort Function
#8
(Jan-14-2021, 08:33 PM)deanhystad Wrote: dastardly is "evil, wicked, cruel". Recursion is dastardly. The solutions are often far from being efficient or understandable. Recursive solutions often have restrictions that cause them to fail for some data sets while working fine for others (recursion depth). Recursion is difficult to debug.

Sometimes a recursive solution is a good solution, but that is just not the case with an insertion sort.

Recursion depth might be a problem, but only under special circumstances. As I pointed out, recursive solutions are often simple: "how do we take one (more) step towards a solution and how do we know when to stop?"
Also, some problems are natural to solve with recursion and others can not be (easily) solved with iteration. Quicksort, mergesort, depth-first search (like binary tree search) are some examples where recursion is much more efficient than iteration (apart from memory usage). The round-off algorithms for floating number operations are often recursive divide-and-conquer algorithms as they generally provide better results than the iterative ones.
So, even if you don't like recursion and even if recursive solutions sometimes are hard to understand and debug, recursion is important and thus important to study.
ndc85430 likes this post
Reply


Messages In This Thread
RE: Combine Two Recursive Functions To Create One Recursive Selection Sort Function - by Serafim - Jan-14-2021, 09:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can i combine these two functions so i only open the file once? cubangt 4 919 Aug-14-2023, 05:04 PM
Last Post: snippsat
  Recursive regular expressions in Python risu252 2 1,325 Jul-25-2023, 12:59 PM
Last Post: risu252
  with open context inside of a recursive function billykid999 1 605 May-23-2023, 02:37 AM
Last Post: deanhystad
Bug New to coding, Using the zip() function to create Diret and getting weird results Shagamatula 6 1,503 Apr-09-2023, 02:35 PM
Last Post: Shagamatula
  python create function validation mg24 1 876 Nov-15-2022, 01:57 AM
Last Post: deanhystad
  create my exception to my function korenron 2 825 Nov-09-2022, 01:50 PM
Last Post: korenron
  Create a function for writing to SQL data to csv mg24 4 1,224 Oct-01-2022, 04:30 AM
Last Post: mg24
  Create SQL connection function and validate mg24 1 979 Sep-30-2022, 07:45 PM
Last Post: deanhystad
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,355 Apr-19-2022, 06:50 PM
Last Post: Gribouillis
  list sort() function bring backs None CompleteNewb 6 4,216 Mar-26-2022, 03:34 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020