Skip to content

Instantly share code, notes, and snippets.

View BenLangmead's full-sized avatar

Benjamin Langmead BenLangmead

View GitHub Profile
{
"metadata": {
"name": "CG_BoyerMooreApprox"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "CG_NaiveApprox"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "CG_TrieMap"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "CG_SuffixTrie"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
def binarySearchSA(t, sa, p):
assert t[-1] == '$' # t already has terminator
assert len(t) == len(sa) # sa is the suffix array for t
l, r = 0, len(sa) # invariant: sa[l] < p < sa[r]
if r == l+1: return r
while True:
c = (l + r) // 2
# determine whether p < T[sa[c]:] by doing comparisons
# starting from left-hand sides of p and T[sa[c]:]
plt = True # assume p < T[sa[c]:] until proven otherwise
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{