ut his invention. Call the first string as A and the se set of all different substrings of A, and T be the se rings of B. We then define another set P which con longs to S or T, but not both. According to the Prof

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Computer science  Cs 102

Question} Using python solve the below problem:
How to measure the difference between two strings? This is a midnight
question of biological scientists. The number of pairs of different characters in
the same position may be a good indicator. However, it will not work well in
the case when two strings have different lengths. The longest common
subsequence will also fail when strings are too long.
Recently, Professor of Math L.P.C. has invented the special method to deal
with this problem. His invention has been known as a simple but creative
solution: the difference is based on the number of substrings (a non-empty
group of consecutive characters) of one string that are not substrings of the
other string.
Let's learn about his invention. Call the first string as A and the second string as
B. Let Ş be the set of all different substrings of A, and T be the set of all
different substrings of B. We then define another set P which consists of all the
strings that belongs to S or T, but not both. According to the Professor L.P.C.
method, the size of P is a good indicator to measure the difference between A
and B
For example, let A = aacd and B = cdaa. We can see that:
%3D
S= {a, aa, aac, aacd, ac, acd, c, cd, d},
T= {c, cd, cda, cdaa, d, da, daa, a, aa},
P = {aac, aacd, ac, acd, cda, cdaa, da, daa}.
Size of P is 8 and we can say the level of difference between A and B is 8.
Your task is to find this indicator. Find a pythonic approach for the solution and
develop an optimized python code. Sample inputs outputs are listed below:
Input:
aacd
cdaa
Output:
8
Transcribed Image Text:Question} Using python solve the below problem: How to measure the difference between two strings? This is a midnight question of biological scientists. The number of pairs of different characters in the same position may be a good indicator. However, it will not work well in the case when two strings have different lengths. The longest common subsequence will also fail when strings are too long. Recently, Professor of Math L.P.C. has invented the special method to deal with this problem. His invention has been known as a simple but creative solution: the difference is based on the number of substrings (a non-empty group of consecutive characters) of one string that are not substrings of the other string. Let's learn about his invention. Call the first string as A and the second string as B. Let Ş be the set of all different substrings of A, and T be the set of all different substrings of B. We then define another set P which consists of all the strings that belongs to S or T, but not both. According to the Professor L.P.C. method, the size of P is a good indicator to measure the difference between A and B For example, let A = aacd and B = cdaa. We can see that: %3D S= {a, aa, aac, aacd, ac, acd, c, cd, d}, T= {c, cd, cda, cdaa, d, da, daa, a, aa}, P = {aac, aacd, ac, acd, cda, cdaa, da, daa}. Size of P is 8 and we can say the level of difference between A and B is 8. Your task is to find this indicator. Find a pythonic approach for the solution and develop an optimized python code. Sample inputs outputs are listed below: Input: aacd cdaa Output: 8
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education