Provide proper documentation as required in the pas provide


Question On Refactoring Programs

Refactor the following code; i.e. improve its quality without modifying its behavior;

Use meaningful names for variables, parameters & functions

Provide proper documentation as required in the PAs

Provide proper indentation & programming style similar to the examples from the textbook, videos & PAs

Remove useless code

Simplify program

Improve performance

You will provide your version in the "Your Modified Version" subsection which is already pre-filled with the original. Then, for each improvement you applied, use the table in the "Summary" subsection to explain what you did & why you did it.

Program to Refactor

int mystery(int v1, int v2){
if( (v1 < 1) || (v2 < 1) ) return 0;
if( v1 < v2 ) return mystery(v1, v2-1)+1;
if( v2 < v1 ) return mystery(v1-1, v2)+1;
return mystery(v1-1, v2-1);
}
Your Improved Version

int mystery(int v1, int v2){
if( (v1 < 1) || (v2 < 1) ) return 0;
if( v1 < v2 ) return mystery(v1, v2-1)+1;
if( v2 < v1 ) return mystery(v1-1, v2)+1;
return mystery(v1-1, v2-1);
}

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Provide proper documentation as required in the pas provide
Reference No:- TGS01066049

Expected delivery within 24 Hours