Provide proper indentation and programming style

Assignment Help Programming Languages
Reference no: EM13785664

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);
}

Reference no: EM13785664

Questions Cloud

How would you define leadership : How would you define leadership
Compose an outline of jane tompkins essay : Compose an outline of Jane Tompkins' essay. What is her thesis? What are the main points she uses to justify her thesis?
Can emma legally enforce her boss promise : Emma Pool is a ultrasound technologist for Mercy Hospital. Emma was approached by a senior official in human resources who represents a competing medical facility. Can Emma legally enforce her boss's promise
Compute additional compensation eligibility for managers : Stellar Packaging Products uses absorption costing to compute additional compensation eligibility for managers. In December, Stellar Packaging Products' controller, Robin Simmons, noted that a considerable production overrun was experienced, resu..
Provide proper indentation and programming style : Provide proper documentation as required in the PAs, Provide proper indentation & programming style similar to the examples from the textbook, videos & PAs
Assignment on integrated business communication : Integrated Business Communication.
Analysis showing the net profit : Provide analysis showing the net profit from (i) the covered call and (ii) the protective put on the expiration date assuming the stock price has fallen 20%. Which strategy is more effective at retaining the value of your position?
Developing a retail advertising campaign issues : Describe the three methods available to the retailer for determining the amount to spend on advertising?
Write about order of things an archaeology of human sciences : Write a journal about "The Order of Things an Archaeology of the Human Sciences".

Reviews

Write a Review

Programming Languages Questions & Answers

  Program to display only unique values which user entered

Program to display only the unique values which the user entered. Give for the "worst case" in which all 20 numbers are different. use smallest possible array to solve this problem.

  Explaining the situation in program

Which of the following best explains the situation after Line 1 has been executed?

  You are consulting for an organization that has unix linux

question 1 the small company where you work needs to implement a second server for its accounting systems but does not

  Write simple program to prompt user for gross salary

Write simple program which will prompt user for his or her gross salary. Your program than will display net salary whereby 11.00% of the gross salary is deducted for EPF

  Write a single line for body of constructor to create object

Create the constructor Orb(int xSpeed, int ySpeed). Write a single line for the body of the constructor,which creates a new Velocity object.

  Write code to takes input from console

Write code using C++ which takes input from console and displays output on console. You will write program which takes user input, does some basic arithmetic, and displays the results.

  Extend the user management

Extend the user management so that user can be stored in database - user can be administrator and he can access that admin page

  Write a program that would allow a user to enter names

Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered.

  Manage the tags associated with web resources

A product that is the tagging of web resources; it would allow the tagging, as well as the management of the tags; perhaps it would include different ways of browsing and visualizing tags (e.g., tag clouds).

  What is the height of the retinal image

Create a binary image at least 64x64 in dimensions. Using Octave's existing functions, perform Average, Gaussian and Laplacian filters on the image. Display the original image and each of the filtered images in Octave plots. Discuss and compare your..

  Program to continuously accepts each worker-s first name

Program which continuously accepts each worker's first and last names, this year's number of units produced, and last year's number of units produced.

  Supporting activity and security personnel

Write a 100- to 200-word short-answer response for the following: Supporting Activity: Security Personnel. Do you think that security personnel require specific skills. Should security practices by an organization be used to prevent the misuse of ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd