File tree 1 file changed +25
-1
lines changed
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 3588
3588
Pos(A3) = Pos($1) + 1 = 8 = 0
3589
3589
Pos(G1) = Pos(A3) + 1 = 1
3590
3590
Pos(A2) = Pos(G1) + 1 = 2
3591
+ - SuffixArray_PatternMatching(Text, Pattern, SuffixArray):
3592
+ minIndex = 0
3593
+ maxIndex = |Text|
3594
+ While mindIndex < maxIndex:
3595
+ midIndex = (minIndex + maxIndex) // 2
3596
+ if Pattern > Suffix of Text starting at position SuffixArray(midIndex):
3597
+ minIndex = midIndex + 1
3598
+ else:
3599
+ maxIndex = midIndex
3600
+ start = minIndex
3601
+
3602
+ maxIndex = |Text|
3603
+ While mindIndex < maxIndex:
3604
+ midIndex = (minIndex + maxIndex) // 2
3605
+ if Pattern < Suffix of Text starting at position SuffixArray(midIndex):
3606
+ maxIndex = midIndex
3607
+ else:
3608
+ minIndex = midIndex + 1
3609
+ end = maxIndex
3610
+
3611
+ if start > end:
3612
+ return "Pattern does not appear in Text"
3613
+ else:
3614
+ return (start, end)
3591
3615
- Space Complexity: ~ 4/K x |* Text* | space with Manber-Myers algorithm
3592
3616
- Matching Pattern running Time:
3593
3617
- It's multiplied by x * K*
3602
3626
- Mismatch # Mismatch # Mismatch # Array Suffix
3603
3627
$1------A1 $1------A1 $1------A1 7
3604
3628
t ->A1------T1 1 A1------T1 A1------T1 6_
3605
- A2------G1 1 A2------G1 t ->A2------G1 0 2 \
3629
+ A2------G1 1 A2------G1 t ->A2------G1 0 2 \
3606
3630
A3------$1 1 A3------$1 A3------$1 1 0 | Approx. Match
3607
3631
b ->A4------C1 0 A4------C1 b ->A4------C1 1 4_ / at {0, 2, 4}
3608
3632
C1------A2 t ->C1------A2 0 C1------A2 3
You can’t perform that action at this time.
0 commit comments