Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ PROGRAM create the function: int subsequence(const string a1[], int n1, const string a2[], int n2); the functions you must write take 4 parameters. array

C++ PROGRAM 

create the function: int subsequence(const string a1[], int n1, const string a2[], int n2);

the functions you must write take 4 parameters. array of strings a1[] and a2[] , and the number of items function will consider in the arrays n1 and n2, starting from the beginning. Basically n1 is the number of interesting elements in a1, and n2 is the number of interesting elements in a2. So when we say "the array", we mean the n elements that the function is aware of. If all n2 elements of a2 appear in a1, consecutively and in the same order, then return the position in a1 where that subsequence begins. If the subsequence appears more than once in a1, return the smallest such beginning position in the array. Return 1 if a1 does not contain a2 as a contiguous subsequence or if n1 or n2 are negative. (Consider a sequence of 0 elements to be a subsequence of any sequence, even one with no elements, starting at position 0.) examples:

string names[10] = { "logan", "reed", "sue", "selina", "bruce", "peter" }; string names1[10] = { "reed", "sue", "selina" }; int t = subsequence(names, 6, names1, 3); // returns 1 string names2[10] = { "logan", "selina" }; int u = subsequence(names, 5, names2, 2); // returns -1 

--------------------------

another example:

string h[7] = { "selina", "reed", "diana", "tony", "", "logan", "peter" };

string e[4] = { "diana", "tony", "", "logan" };

assert(subsequence(h, 7, e, 4) == 2);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago