Linked list in Java - comparing two lists?

I'll assume that you use the usual node structure with a data element and a reference to the next node. Then one can define the function as follows.

I'll assume that you use the usual node structure with a data element and a reference to the next node. Then one can define the function as follows: contains(null, haystack) = true (since every string contains the empty string) contains(pattern, null) = false (since the empty string doesn't contain any patterns) contains(pattern, haystack) = contains(pattern. Next, haystack.

Next) if pattern. Data = haystack. Data (we found a match and proceed to the next item in both lists) contains(pattern, haystack) = contains(pattern.

Next, haystack. Next) else (we found no match and try it with the next character in the haystack).

The in order requirement also simplifies the problem. Consider that both lists are iterated over at the same time with slightly different advancing rules: When is the list "to find" advanced to the next node? When is the list which may contain the "to find" list advanced to the next node?

At what point is it determined that the "to find" list is not contained in the other? At what point is a match determined? How can it be done iterating each list?

How can it be done recursively? Happy coding.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions