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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started