Introduction to Recursive Programming by Manuel Rubio-Sanchez
Author:Manuel Rubio-Sanchez [Rubio-Sanchez, Manuel]
Language: eng
Format: azw3, pdf
Publisher: CRC Press
Published: 2017-10-05T04:00:00+00:00
6.2.2 The quicksort algorithm
The quicksort algorithmAlgorithm!sorting!quicksort is another method developed by Tony Hoare. It is based on the divide and conquer approach and receives its name due to its remarkable efficiency. Unlike the merge sort algorithm, its running time in the worst case is O ( n 2 ) . However, in the best and average cases it runs in Θ ( n log n ) time, and can be several times quicker than the merge sort algorithm in practice.
To understand the difference between both methods, observe that the decomposition in merge sort is easy. In particular, the input list can be divided in two halves by simply using appropriate index ranges (0:n//2 and n//2:n). However, combining the results of the subproblems requires solving yet another problem (merge) that is not immediately straightforward. In contrast, in the quicksort algorithm the decomposition is hard, but the combination stage is not only trivial, but may not even be necessary in some implementations.
Specifically, instead of simply dividing the list in two halves, quicksort’s decomposition transforms the input by using a partitioning scheme like the ones presented in Section 5.4. Figure 6.2 illustrates this type of decomposition, where the sublists within the original list are separated by a pivot (the sublist to the right of the pivot contains elements that are less than or equal to the pivot, and the sublist to the left is composed of numbers that are greater than the pivot). A concrete recursive diagram based on the previous decomposition could be:
Download
Introduction to Recursive Programming by Manuel Rubio-Sanchez.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Modelling of Convective Heat and Mass Transfer in Rotating Flows by Igor V. Shevchuk(6203)
Weapons of Math Destruction by Cathy O'Neil(5779)
Factfulness: Ten Reasons We're Wrong About the World – and Why Things Are Better Than You Think by Hans Rosling(4455)
Descartes' Error by Antonio Damasio(3139)
A Mind For Numbers: How to Excel at Math and Science (Even If You Flunked Algebra) by Barbara Oakley(3076)
Factfulness_Ten Reasons We're Wrong About the World_and Why Things Are Better Than You Think by Hans Rosling(3025)
TCP IP by Todd Lammle(2983)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2859)
Fooled by Randomness: The Hidden Role of Chance in Life and in the Markets by Nassim Nicholas Taleb(2835)
The Tyranny of Metrics by Jerry Z. Muller(2819)
The Book of Numbers by Peter Bentley(2744)
The Great Unknown by Marcus du Sautoy(2516)
Once Upon an Algorithm by Martin Erwig(2457)
Easy Algebra Step-by-Step by Sandra Luna McCune(2435)
Lady Luck by Kristen Ashley(2386)
Practical Guide To Principal Component Methods in R (Multivariate Analysis Book 2) by Alboukadel Kassambara(2358)
Police Exams Prep 2018-2019 by Kaplan Test Prep(2334)
All Things Reconsidered by Bill Thompson III(2242)
Linear Time-Invariant Systems, Behaviors and Modules by Ulrich Oberst & Martin Scheicher & Ingrid Scheicher(2210)
