(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 Please let me know the solution which gives exact mentioned outputs in question
(String Matching): Write a
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
Please let me know the solution which gives exact mentioned outputs in question
Step by step
Solved in 3 steps with 3 images