You have (0) items in your Wishlist
No Items in Wishlist

To add items to your wishlist, simply click the "Add to Wishlist" link from any product page.

R Experiment 5 (quicksort v3) by xiluembo
Added to wishlist
R Experiment 5 (quicksort v3) by xiluembo
Keep shopping

R Experiment 5 (quicksort v3) Rug

R Experiment 5 (quicksort v3) Rug
Double-tap to zoom
R Experiment 5 (quicksort v3) Rug
Double-tap to zoom
R Experiment 5 (quicksort v3) Rug
Double-tap to zoom
R Experiment 5 (quicksort v3) Rug
Double-tap to zoom
To collect and promote designs, you must be a logged-in member
Create accountAlready a member? Sign in
R Experiment 5 (quicksort v3) by

Reimagine the classic home decor essential: our Rugs feature one-of-a-kind designs printed on a subtle chevron weave. From understated styles to bold statements, find the perfect throw rug to accent any room.

  • Available in three sizes
  • Crafted with 100% woven polyester
  • Subtle, durable chevron weave
  • Machine washable
  • Skid pad is included
Made to order
Each Society6 product is individually printed and assembled when you order it, so please allow 3-5 days manufacture time for your custom product.
No-hassle returns
We want you to be stoked with your purchase, so if you’re not, let us know. We offer a 100% Happiness Guarantee, which means free refunds and exchanges.
Every purchase pays an artist
Society6 artists live all over the world, and every purchase puts money right in their pockets. We’ve been helping artists do what they love since 2009.
Also available as

Artwork programmatically written in R, demonstrating the quicksort algorithm over a full saturation pattern. This is pretty the same of the previous two experiments, but instead of using "middle" pivot, the pivot is now random.


dimensions <- data.frame(w=c(1300,3300,6000,6500,4600,4600), h=c(2000,5100,9000,6500,2000,3000))

RNGkind(kind = "Knuth-TAOCP-2002") set.seed(8486)

#non-recursive quicksort qsort.nrec.steps <- function(v) { left <- 1 right <- length(v)

rightStack &lt;- right
leftStack &lt;- left

history &lt;- v

repeat {
    if ( right &gt; left ) {    
        i &lt;- left
        j &lt;- right
        pivot &lt;- sample(left:right, size=1)
        repeat {
            while (pivot &gt; v[i]) {
                i &lt;- i + 1
            while (pivot &lt; v[j]) {
                j &lt;- j - 1
            if ( i &lt;= j ) {
                v[c(i,j)] &lt;- v[c(j,i)]
                i &lt;- i + 1
                j &lt;- j - 1
                history &lt;- rbind(history, v)
            if(i &gt; j) {
        rightStack &lt;- c(j, rightStack)
        leftStack &lt;- c(left, leftStack)
        left &lt;- i
    } else {
        right &lt;- rightStack[1]
        rightStack &lt;- rightStack[-1]
        left &lt;- leftStack[1]
        leftStack &lt;- leftStack[-1]
    if ( length(rightStack) == 0 ) {



for ( i in 1:nrow(dimensions) ) { d <- dimensions[i,] width <- min(d$w, d$h) height <- max(d$w, d$h)

unit.w &lt;- width %/% ( min(width,height) %/% 2 )
units &lt;- width %/% unit.w

img.r &lt;-, width * height)
img.g &lt;-, width * height)
img.b &lt;-, width * height)

dim(img.r) &lt;- c(height, width)
dim(img.g) &lt;- c(height, width)
dim(img.b) &lt;- c(height, width)

colors = sample(x=1:units, size=units, replace=FALSE)

sorting.hist &lt;- qsort.nrec.steps(colors)

if (nrow(sorting.hist) &lt; height) {
    qty.fill &lt;- height - nrow(sorting.hist)
    fill &lt;- rep(sorting.hist[nrow(sorting.hist),], times=qty.fill)
    fill &lt;- matrix(fill, ncol=units, byrow=TRUE)
    sorting.hist &lt;- rbind(sorting.hist, fill)

colorset &lt;- rainbow(units)

for(rw in 1:height) {
    for(cl in 1:units) {
        img.r[rw,(unit.w*(cl-1)+1):(unit.w*(cl))] = col2rgb(colorset[sorting.hist[rw,cl]])[1,]
        img.g[rw,(unit.w*(cl-1)+1):(unit.w*(cl))] = col2rgb(colorset[sorting.hist[rw,cl]])[2,]
        img.b[rw,(unit.w*(cl-1)+1):(unit.w*(cl))] = col2rgb(colorset[sorting.hist[rw,cl]])[3,]


if ( d$w &lt;= d$h ) {
    img.res &lt;- c(img.r, img.g, img.b) / 255
} else {
    img.res &lt;- c(t(img.r), t(img.g), t(img.b)) / 255
dim(img.res) &lt;- c(d$h,d$w,3)

writeJPEG(img.res, target=paste0("Rx5_", width, "x", height, ".jpg"), quality=1)


R, HSV, computer, generated, random, pattern, abstract, rainbow

More from this artist

Verified member since 1970
Shop all from this artist

Reviews: All Society6 Rugs

R Experiment 5 (quicksort v3)
Leave a comment