Question: *****************CODE SHOULD BE WRITTEN IN C++*************************************** Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences

*****************CODE SHOULD BE WRITTEN IN C++***************************************

Given a text txt[0..n-1] and a pattern pat[0..m-1],

write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[].

You may assume that n > m.

************************************USE FUNCTION BELOW************************************************

#include "problem1.h" #include using namespace std;

void search(char* pat, int M, char* txt, int N) { //pLEASE TYPE CODE HERE }

************************EXAMPLE***********************8

Input: txt[] = "THIS IS A TEST TEXT" pat[] = "TEST" Output: Pattern found at index 10 Input: txt[] = "AABAACAADAABAABA" pat[] = "AABA" Output: Pattern found at index 0 Pattern found at index 9 Pattern found at index 12

*

********************************************************************************************

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!