Let's now go ahead and discuss the pseudocode for the recursive approach that we have just now discussed
in the previous video.
So we would need to write a function.
And this function will have some inputs.
And inside this function we would have to write the base case and the recursive case.
Now we have already discussed the three possibilities for the base case.
Now when it comes to these inputs over here we'll need two indices index one, which can be used as
a pointer to iterate over the characters in word one.
And let's say we are using index two to iterate over the characters in word two.
Now in the base case, we have three possibilities.
So if both of these become greater than the last valid indices in word one and word two together, then
we can just return zero, or if only one of them is greater than the last valid index, and there are
still valid characters in the other word, then we would have to return the number of remaining characters.
In the other word.
So we have discussed this in the previous video.
And when it comes to the choice diagram, we have discussed that there are two possibilities at a high
level.
One is that we find that the characters at index one and index two in word one and word two, respectively,
are equal.
And the other possibility is that we see that the two characters are not equal.
Now, if they are equal, we don't need to do any operations, and we can just find the number of operations
required for the remaining parts of word one and word two, respectively.
Now, if they are not equal, we have discussed that there are three possibilities insert, delete and
replace.
Now we have seen how to move the indices index one and index two in these three cases in the previous
video.
So for each of these we would have to find the answer.
So insert would be one plus.
Again recursively calling the function with the respective indices.
As we have discussed in the previous video.
And we would have to do the same thing for delete and replace.
And then we would have to return the minimum among these three values that we get.
So this is how we will recursively solve this question.
And this is the pseudocode for the approach that we have discussed.