String Matching): Write a program to use Horspool’s Algorithm to find the pattern in the string. You can define two variables called Text and Pattern. Please display shift table for that pattern and display the shift value for each step. If not match, display a message “Unsuccessful Search”. If match, display the index. For example, If Text =“BARD LOVED BANANAS” and Pattern=”BAOBAB”. The result will be: Shift Table: A=1, B=2, O=3, other=6 Shift 6, shift 2, shift 6, pattern not found If Text=”BARD LOVED BABAOBABANAS” and Pattern=”BAOBAB”. The result will be: Shift Table: A=1, B=2, O=3, other=6 Shift 6, shift 2, shift 2, shift 3, pattern found at position 13 Language preferred is python
String Matching): Write a program to use Horspool’s
You can define two variables called Text and Pattern.
Please display shift table for that pattern and display the shift value for each step. If not match, display a message “Unsuccessful Search”. If match, display the index.
For example,
If Text =“BARD LOVED BANANAS” and Pattern=”BAOBAB”.
The result will be:
Shift Table: A=1, B=2, O=3, other=6
Shift 6, shift 2, shift 6, pattern not found
If Text=”BARD LOVED BABAOBABANAS” and Pattern=”BAOBAB”.
The result will be:
Shift Table: A=1, B=2, O=3, other=6
Shift 6, shift 2, shift 2, shift 3, pattern found at position 13
Language preferred is python
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images