Question: In computer applications, pattern matching is used to find a given pattern within a piece of text. Different systems may have different rules or types

In computer applications, pattern matching is used to find a given pattern within a piece of text. Different systems may have different rules or types pattern matching. One particular system empoys the following rules for pattern matching. The system counts the locations starting from 0. THat is, th e first character location is 0, the second characyer location is 1, etc. The system allows two types of matching : on exact match and a closet match.Exact match is when all the characters in the pattern are ofund exactly whithin the text. For example, if the text is "three big apple trees" and the [pattern is "apple tree", there is an exact match at location 10. Closest match is when there is a mismatch in any one character, but all the other characters of the pattern are found exactly within the text For example, if the text is "Three big apple trees" and the patter is "bug apple", there is a closest match at locanon 6. The pattem is found for all characters except the second
tharacter u There is a mismatchinontyone character, so this is a closest match. Uppercase and lowercase letters are considered different. for exaample, if the text is "three big apple tress" and the pattern is "Big Apple", there is no match.But if the pattern is "big apple", there is a match at location 6. Given a text and pattern, print the location of the first exact or closest match. if there are no matches, print No match found. If the pattern is longer than the text, print Invalid input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!