Question: Can someone help me with this problem using c++. Thank you. Find all indices in a char array A at which a pattern P occurs.

Can someone help me with this problem using c++. Thank you.  Can someone help me with this problem using c++. Thank you.

Find all indices in a char array A at which a pattern P occurs. This program has the user input a longish character array A, and then a shorter character array P(P contains the pattern), and constructs and displays an array -which we will call I - containing a indices at which (possibly overlapping) occurrences of P start in A, in the order in which these occur. Thus if A is a b a a b a a a b a a a a b b and P is a b, then l will contain 0, 3, 7, and 12. And if instead P is a a, then the contents of I would be 25 69 10 11-note carefully how the overlaps factor in here. Another example: if A is a b a b a b a b c c c d and P is a b a, then I contains 0 2 4 When the program prints the array I, it prints only the part of I which has been used -see the text's discussion of partially filled arrays. By setting the global const bool nonOverlappingOnly to true, the program reports only non-overlapping occurrences of P In this case, the output for the first example above is 2 5 9 11, and the output for the second example is 0 4

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!