2.0

2.0 | 1 rating Rate this file 15 Downloads (last 30 days) File Size: 2.15 KB File ID: #29389

Quicksort MATLAB

by GAGAN

 

13 Nov 2010 (Updated 07 Apr 2011)

Implementation of standard quicksort Algorithm in MATLAB.

| Watch this File

File Information
Description

It uses recursion to to implement quicksort. For the purpose of partitioning pivot is chosen according to median-of-three scheme.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
18 Nov 2010 James Tursa

There is absolutely NO help with this submission. No H1 line, and absolutely 0 comments in the code. So you have to edit the code to figure out how to run it, and make guesses as to the desired inputs based on the variable names used. So I made some guesses and here is a quick (pun intended) example:

>> a = rand(1,100000);
>> tic;b=sort(a);toc
Elapsed time is 0.011785 seconds.
>> tic;[c,CPU_cost]=quicksort(a,1,100000,0);toc
Elapsed time is 113.274774 seconds.
>> isequal(b,c)
ans =
     1

So this modest sized data set ran almost 10,000 times slower than MATLAB's built-in sort function. For a large data set I can only imagine it would take hours or days to complete. So this is not a useful function for any practical use. It *might* serve as a simple algorithm example for someone, but even that is severely diminished by the fact that there is not one line of comments in the entire code package ... not one. I give it a 2 star rating instead of a 1 star rating only because it did produce the same result as MATLAB ... at least for my one spot check.

Please login to add a comment or rating.
Updates
07 Apr 2011

Added new tags.

Tag Activity for this File
Tag Applied By Date/Time
quicksort GAGAN 15 Nov 2010 11:10:32
quicksort matlab GAGAN 15 Nov 2010 11:10:32
sort GAGAN 15 Nov 2010 11:10:32
sort matlab GAGAN 15 Nov 2010 11:10:32
quick GAGAN 15 Nov 2010 11:10:32
quick matlab GAGAN 15 Nov 2010 11:10:32
soring in matlab GAGAN 15 Nov 2010 11:10:33
sorting GAGAN 15 Nov 2010 11:10:33
sort in matlab GAGAN 15 Nov 2010 11:10:33
quicker GAGAN 07 Apr 2011 15:30:26
quicker matlab GAGAN 07 Apr 2011 15:30:26

Contact us at files@mathworks.com