# Examples of *MOQA* Programs

We provide several examples of well-known algorithms for sorting and searching, programmed in *MOQA*. Two new sorting algorithms are introduced, Percolating Heapsort and Treapsort, based on the *MOQA*deletion operation. Percolating Heapsort provides the first randomness preserving version of Heapsort.

In the following examples *X*denotes the input *S*-variable while *Z*denotes the output *S*-variable.

We adopt the convention in the presentation that*MOQA*algorithms when called on orders of size 0 or 1 act as the identity operation, i.e. will simply return the datalabeling of a partial order of size 0 or 1.

Moreover, when referring to a call to a basic operation on an *S*-variable *X*, we assume implicitly that the data-labeling stored in the variable*X*is reset to the output data-labeling computed by the basic operation. For instance, we will refer to *Top*(*X*) as opposed to [*X*:= *Top*(*X*)] in the pseudo-code.

## Keywords

Partial Order Binary Tree Selection Phase Random Structure Sorting Algorithm## Preview

Unable to display preview. Download preview PDF.