Skip to content

Instantly share code, notes, and snippets.

View petar-dambovaliev's full-sized avatar
👶

Petar Dambovaliev petar-dambovaliev

👶
  • Somewhere over the rainbow
View GitHub Profile
@petar-dambovaliev
petar-dambovaliev / skew-algorithm.md
Created December 29, 2018 18:33 — forked from markormesher/skew-algorithm.md
The Skew (Linear Time) Algorithm for Suffix Array Construction

The Skew (Linear Time) Algorithm for Suffix Array Construction

I'll use x = "processing" as an example. Throughout the example * represents the null character, which sorts before any other character (i.e. * < a < b < c < ...).

We start by creating three groups of suffixes - S0, S1 and S2 - so that each suffix in the group Sk starts at the index 3q + k for some value of q. In plain English:

  • S0 suffixes start at positions 0, 3, 6, etc.
  • S1 suffixes start at positions 1, 4, 7, etc.
  • S2 suffixes start at positions 2, 5, 8, etc.
@petar-dambovaliev
petar-dambovaliev / grace.go
Created December 7, 2018 10:16 — forked from rcrowley/grace.go
Graceful stop in Go
package main
import (
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"