Implement Quicksort

The Wolfram Compiler allows efficient implementation of a variety of standard algorithms, for example, quicksort. Many of these algorithms operate on compound types, such as arrays, that can be indicated using TypeSpecifier.

The following is a straightforward implementation of quicksort, focusing on minimum code rather than maximum speed. TypeSpecifier is used to indicate that the input is a depth-1 array of machine integers, and FunctionCompile automatically determines that the return value is also an array of the same type.

In[1]:=1
Out[1]=1

Generate data to be sorted.

In[2]:=2
Out[2]=2

Sort the data.

In[3]:=3
Out[3]=3

Related Examples

Find out if you already have access to Wolfram tech through your organization
×