-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix heading issue
- Loading branch information
Showing
6 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
== HW9 (Week 11) | ||
Due: 2024.05.19 | ||
|
||
#let ans(it) = { | ||
box(inset: 1em, width: 100%)[ | ||
#text(fill: blue)[ | ||
#it | ||
] | ||
] | ||
} | ||
|
||
=== Question 32.4-1 | ||
Compute the prefix function $pi$ for the pattern `ababbabbabbababbabb`. | ||
|
||
#ans[ | ||
$ | ||
pi={0,0,1,2,0,1,2,0,1,2,0,1,2,3,4,5,6,7,8} | ||
$ | ||
] | ||
|
||
=== Question 32.4-6 | ||
Show how to improve KMP-MATCHER by replacing the occurrence of $pi$ in line 5(but now line 10) by $pi'$, where $pi'$ is defined recusively for $q=1,2...,m-1$ by the equation | ||
$ | ||
pi'[q]=cases(0 quad & "if" pi[q]=0, pi'[pi[q]] quad &"if" pi[q]!=0 "and" P[pi[q]+1]=P[q+1], pi[q] quad & "otherwise") | ||
$ | ||
|
||
Explain why the modified algorithm is correct, and explain in what sense this change constitutes an improvement. | ||
|
||
#ans[ | ||
If $P[q+1]!=T[i] "and" P[pi[q]+q]=P[q+1]!=T[i]$, there's no need to compare $P[pi[q]+q]$ with $T[i]$, because $P[pi[q]+q]$ is the same as $P[q+1]$, so we can directly compare $P[q+1]$ with $T[i]$. This change improves the efficiency of the algorithm. | ||
] | ||
|
||
#align(center)[ | ||
#image("imgs/sticker_2.jpg", width: 50%) | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
PB21000030 马天开 | ||
|
||
#include "hw9.typ" | ||
#pagebreak() | ||
#include "hw8.typ" | ||
#pagebreak() | ||
#include "hw7.typ" | ||
|