Salve! Ho questo problema. Avendo due liste collegate con puntatori devo verificare che la prima lista sia una sottolista (sotto sequenza) della seconda.
codice:
struct List
{
	int value;
	struct List * nextPtr;
};

Boolean match(struct List * ptr1, struct List * ptr2)
/* Restituisce TRUE se il prefisso di ptr1 e' uguale al prefisso di ptr2 */
{
	Boolean match;

	match = TRUE;
	while(ptr2 != NULL && match == TRUE)
	{
		if(ptr1 == NULL || ptr2->value != ptr1->value)
			match = FALSE;
		else
		{
			ptr2 = ptr2->nextPtr;
			ptr1 = ptr1->nextPtr;
		}
	}
	return (match);
}

Boolean scan4match(struct List * ptr1, struct List * ptr2)
/* Riceve in ingresso due sequenze di interi s1 e s2 rappresentate come liste
 * in forma collegata con puntatori e verifica se s1 è una sottosequenza di s2.*/
{
	Boolean found;
	found = FALSE;
	while(ptr1 != NULL && found == FALSE)
	{
		if(match(ptr1, ptr2) == TRUE)
			found = TRUE;
		else
			ptr1 = ptr1->nextPtr;
	}
	return found;
}
scan4match è la funzione in questione. Se ho la lista {1,2,5} e la lista {1,2,3,4} mi restituisce FALSE perchè?