Question: #include #include #define MAXLENGTH 100 int one_away(char str1[], char str2[]); int str_length(char str[], int max_length); void swap_int(int * x, int *y); void swap_str(char ** str1,
![#include #include #define MAXLENGTH 100 int one_away(char str1[], char str2[]); int](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66dfd774a2679_71666dfd77420063.jpg)
![str_length(char str[], int max_length); void swap_int(int * x, int *y); void swap_str(char](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66dfd77525bb8_71666dfd774cdc55.jpg)
#include
#define MAXLENGTH 100
int one_away(char str1[], char str2[]); int str_length(char str[], int max_length); void swap_int(int * x, int *y); void swap_str(char ** str1, char ** str2);
char str[] = "pale"; char strA[] = "ple"; char strB[] = "payle"; char strC[] = "bale"; char strD[] = "bake"; char strE[] = "sale"; char strF[] = "ale"; char strG[] = "al";
void main() { printf("'%s' and '%s' have result %d ", str, strA, one_away(str, strA)); printf("'%s' and '%s' have result %d ", str, strB, one_away(str, strB)); printf("'%s' and '%s' have result %d ", str, strC, one_away(str, strC)); printf("'%s' and '%s' have result %d ", str, strD, one_away(str, strD)); printf("'%s' and '%s' have result %d ", str, strE, one_away(str, strE)); printf("'%s' and '%s' have result %d ", str, strF, one_away(str, strF)); printf("'%s' and '%s' have result %d ", str, strG, one_away(str, strG)); }
int one_away(char str1[], char str2[]) { return 0; }
int str_length(char str[], int max_length) { int length; for (length = 0; (str[length] != '\0') && (length There are three types of "edits" that can be performed on strings: - insert a character - remove a character - replace a character Attached find the program OneAway.c. It has a function int one_away(char str1[], char str2[]); that will check if the strings str1 and str2 are at most one edit away (i.e., zero or one edit away). It returns 1 if the strings are at most one edit away, and returns 0 otherwise. (Note that program oneAway.c also has a function "str_length" which will return the length of a string.) FXAMPIFS The current function one_away doesn't work. So change it, so that it does work. Your function should have time complexity O(n), where n is the sum of lengths of the two strings. The output should be as follows: 'pale' and 'ple' have result 1 'pale' and 'payle' have result 1 'pale' and 'bale' have result 1 'pale' and 'bake' have result 0 'pale' and 'sale' have result 1 'pale' and 'ale' have result 1 'pale' and 'al' have result 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
