5

Can someone explain in English how non-recursive and recursive implementations of sorting algorithms differs from each other?

0

3 Answers 3

6

How they differ, in what sense? Bear in mind: any recursive algorithm can be implemented as an iterative algorithm, and vice versa (take a look at this post). Iteration or recursion - it's just an implementation detail; although it can have a major impact in performance depending on the choice, the algorithm will be the same nevertheless.

Sign up to request clarification or add additional context in comments.

Comments

2

Recursive sorting algorithms work by splitting the input into two or more smaller inputs and then sorting those, then combining the results. Merge sort and quick sort are examples of recursive sorting algorithms.

A non-recursive technique is anything that doesn't use recursion. Insertion sort is a simple example of a non-recursive sorting algorithm.

2 Comments

This is mostly true, so I won't downvote it, but any recursive algorithm, sorting or not, can be made into a non-recursive (aka iterative) algorithm.
Insertion Sort can be implemented recursively as well. Here is one example: geeksforgeeks.org/recursive-insertion-sort
0

A recursive sorting algorithm calls on itself to sort a smaller part of the array, then combining the partially sorted results. Quick-sort is an example.

A non-recursive algorithm does the sorting all at once, without calling itself. Bubble-sort is an example of a non-recursive algorithm.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.