Assignment 9
Assignment 9
Assignment
4. Name your file as <roll_no>_a<asst_no>. For example, if your roll number is 14CS10001
and you are submitting Assignment 1, then name your file as 14CS10001_a1.c or
14CS10001_a1.cpp as applicable.
5. Write your name, roll number, and assignment number at the beginning of your program.
7. Submit your program on Moodle before deadline. Submissions by email or any other means will
NOT be considered for evaluation.
Given three strings x, y, s, s is said to be an interleaving of x and y if the characters of s are formed by
the characters of x and y, plus x is a subsequence of s and y is also a subsequence of s. Eg. ADEBCF is
interleaving of ABC and DEF. If s is an interleaving of x and y and there is a common character in x and
y then that character appears multiple times in s. Eg. ACDABC is interleaving of ABC and ACD.
The Hamming distance between 2 strings s1 , s2 of the same length is the number of indices where
the two strings differ. Eg. rat and bat have a Hamming distance of 1.
Write a program to do the following:
1. Take as input 3 strings x, y, s. Let the length of x and the length of y be m and n respectively.
4. Print the interleaving of x and y that has a Hamming distance of 1 with s, or say that no such
interleaving exists.
1
Sample Output
Input x: abcd
Input y: efgh
Input s: aefbghcd
$s$ is an interleaving of $x$ and $y$
Input x: abcd
Input y: efgh
Input s: abclfdgh
abcefdgh is an interleaving of x and y that has Hamming distance 1 with s
Policy on Plagiarism
Academic integrity is expected from
all the students. You should work on
the assignment/exam consulting
only the material we share with you.
You are required to properly
mention/cite anything else you look
at. Any student submitting
plagiarized code will be penalized
heavily. Repeated violators of our
policy will be deregistered from the
course. Read this to know what is
plagiarism.