I'm trying to get a recursive Function, which should compare two int arrays and say wether array2 is a subsequence of array1. My Problem is now that i dont know when to set the return value of an bool recursive function. I'm glad for every help.
int array1 [] = {1 ,2 ,3 ,4 ,5 ,6,7,8,9,10};
int array2 [] = {2,4,6,8};
int l1 = 10;
int l2 = 4;
bool isSubset ( int p1 , int p2) {
while (p1 <= l1) {
if (array1[p1] == array2[p2]) {
isSubset(p1 + 1, p2 + 1);
} else {
isSubset(p1 + 1, p2);
}
}
}
int main (void) {
if ( isSubset(0,0))
cout << "yes" << endl ;
else
cout << " no " << endl ;
return 0;
}