Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write in Java programming please also take a screenshort of your work, Use IJ application G. (Searching for longest common string within the sliding window)

write in Java programming please also take a screenshort of your work, Use IJ application image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
G. (Searching for longest common string within the sliding window) Dynamic programming (dp) is the most common algorithm used to search for the longest common string (cs). However, dp is a memory consuming algorithm, though it is simple in code implementation. Here I'm asking you to use another algorithm in assistance of sliding window as shown in following figure We are going to search for Ics between string s1 and s2 1. Let's brief how it works in window first As shown in fig, we have window size 2, the sliding window (let's call it w1) of of st is at the index 0, and s2's w2 is at the index of 1 We'll compare s1[O] to s2[1] first, then s1[1] to s2[2] and get the 0 same characters, we then slide w2 one cell forward, and do the same comparison within w1 and 2 2. w1 will start from index 0, for each sliding of w1, W2 is going to have a full sliding from index 0 to the end. For each sliding of w2, it will repeat step 1 to find out the length of common string 3. when w1 reaches the end, we'll get the longest common string within the window with the window index. We will then start from that index and print the same character till meet the different characters of two strings. 4 for example, in figure, through the full search, we found when w1 and w2 both at the index 0 has Ics he length 2. Then we start from from index 0 in s1 and 0 in s2, move the index at the same time right, and do the comparison printing the common string as he Be noted: if there are multiple Ics found within the window, take the first occurrence only. Therefore, the size of the window will affect the Ics we found, e.g. following if we set window size as 3, we'll find ics result oworl. windowSize s1h e || | 0 w 0 1 d S2 h e alb 0 W 0 T | f d 0 1 2 3 4 5 6 7 8 9 10 Input ,,2s1 52,windowSize(), The input only one testing data with one line, two strings s1 and s2 with whitespace between and followed by window size Output , print the ics with change new line at the end Examples input helloworld heaboworlfd 2 helloworld heaboworlfd 3 dynamicprogramming jmitamicpghmer 7 output he oworl amicp G. (Searching for longest common string within the sliding window) Dynamic programming (dp) is the most common algorithm used to search for the longest common string (cs). However, dp is a memory consuming algorithm, though it is simple in code implementation. Here I'm asking you to use another algorithm in assistance of sliding window as shown in following figure We are going to search for Ics between string s1 and s2 1. Let's brief how it works in window first As shown in fig, we have window size 2, the sliding window (let's call it w1) of of st is at the index 0, and s2's w2 is at the index of 1 We'll compare s1[O] to s2[1] first, then s1[1] to s2[2] and get the 0 same characters, we then slide w2 one cell forward, and do the same comparison within w1 and 2 2. w1 will start from index 0, for each sliding of w1, W2 is going to have a full sliding from index 0 to the end. For each sliding of w2, it will repeat step 1 to find out the length of common string 3. when w1 reaches the end, we'll get the longest common string within the window with the window index. We will then start from that index and print the same character till meet the different characters of two strings. 4 for example, in figure, through the full search, we found when w1 and w2 both at the index 0 has Ics he length 2. Then we start from from index 0 in s1 and 0 in s2, move the index at the same time right, and do the comparison printing the common string as he Be noted: if there are multiple Ics found within the window, take the first occurrence only. Therefore, the size of the window will affect the Ics we found, e.g. following if we set window size as 3, we'll find ics result oworl. windowSize s1h e || | 0 w 0 1 d S2 h e alb 0 W 0 T | f d 0 1 2 3 4 5 6 7 8 9 10 Input ,,2s1 52,windowSize(), The input only one testing data with one line, two strings s1 and s2 with whitespace between and followed by window size Output , print the ics with change new line at the end Examples input helloworld heaboworlfd 2 helloworld heaboworlfd 3 dynamicprogramming jmitamicpghmer 7 output he oworl amicp

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago