3. What will be the output of the following Go code snippet using Rabin Karp to find pattern "abc" in text "ababc"?
package main
import "fmt"
func main() {
text := "ababc"
pattern := "abc"
// Simplified hash values for illustration
patternHash := 294
textHash := 0
base := 256
prime := 101
for i := 0; i <= len(text)-len(pattern); i++ {
if i == 0 {
for j := 0; j < len(pattern); j++ {
textHash = (textHash*base + int(text[j])) % prime
}
} else {
textHash = (base*(textHash-int(text[i-1])*intPow(base, len(pattern)-1)) + int(text[i+len(pattern)-1])) % prime
if textHash < 0 {
textHash += prime
}
}
if textHash == patternHash {
fmt.Println("Pattern found at index", i)
}
}
}
func intPow(a, b int) int {
result := 1
for b > 0 {
result *= a
b--
}
return result
}