(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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 9SA
icon
Related questions
Question
100%

(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

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Literals
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning