Question: Call two strings s 1 and s 2 similar if , for each distinct character in s 1 , it is possible to replace all
Call two strings s and s similar if for each distinct character in s it is possible to replace all occurrences of it by another character possibly itself uniquely such that, after all replacements are done to s we end up with s For example:
The strings s "adt" and sbst are similar, because the replacements abds and tt transform s into s
The strings s "adt" and sdcc are not similar. The only possible replacement addc and tc does transform s into s but is invalid because it violates uniqueness we have two characters that get replaced with c
The strings saa and sbc are not similar, because to transform s into s we need to replace a with two different characters, but this is not allowed.
Note that the replacements must occur independently of each other ie in the second example, we don't replace each a by d before replacing each d by c as the result would be that each a also gets replaced by c
Your task is to implement the following function in similar.c using the HashTable ADT to write an algorithm that determines if two strings are similar:
bool areSimilarStringschar s char s;
Testing
similar.c contains a main function which allows you to test your areSimilarStrings function. It accepts two strings as commandline arguments which will be passed to your function. Here are some examples of its usage, and some expected outputs:
make
similar adt bst
The strings are similar
similar adt dcc
The strings are not similar
similar aa bc
The strings are not similar
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
