You are given a string X of length n and another string Y of length
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

You are given a string X of length n and another string Y of length

Q3:

You are given a string X of length n and another string Y of length m ≤ n. Say, the indexes P1, P2, P3, P4 and q1, q2, q3, q4 form two sub-sequences, i.e., 0 ≤ p1 < P2 <P3 < P4 <n and 0 ≤ q1 < q2 < q3< q4 < n; then, they are non-overlapping if p4 < q1.

The task is to count the maximum number of non-overlapping sub-sequences of X that are the same as Y. Thus, if X = GAXTYAWBGTAUGBTABGRGTAXB and Y = GTAB, then the answer is 3 as shown by the red fonts. We cannot select the underlined GTAB as it overlaps with a red GTAE (i.e., among overlapping sub-sequences, you can select only one of them).

Describe an O(m+n) time algorithm to obtain the count. Write a pseudo-code.

Hint
ComputerThe non-overlapping requirement is a useful criteria for removing redundant subsequences because the overlapped subsequences usually indicate the same instance with little time shift. Note that the non-overlapping examination may introduce the extra delay in reporting qualified subsequences....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.