Menu

[Solved]B Write Function Signature Int Finddup Const Char S Int N Returns 1 True String S Contains Q37033754

b) Write a function with signature

int find_dup(const char s[ ], int n)

that returns 1 (True) if string s contains a duplicatedsubstring of length n and 0 otherwise. A duplicated substring in sis a substring (1 or more consecutive characters in s) that isrepeated at least twice. The first and second copies of thesubstring may overlap.

To get any credit do not use any functions from string.h exceptfor strlen..

Examples: find_dup(“funny bunnies”, 3) returns 1 since substring“unn” is duplicated. Also, substrings “un”, “u”, “n” areduplicated, too, so find_dup(“funny bunnies”, 2) andfind_dup(“funny bunnies”, 1) return 1 as well. On the other hand,find_dup(“program”, 2) returns 0 as there are no substrings oflength 2 that are repeated.

Expert Answer


Answer to b) Write a function with signature int find_dup(const char s[ ], int n) that returns 1 (True) if string s contains a dup… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *