In: Computer Science
Use C++, Java, or Python3 to create your own algorithm to complete a computing task.
There are four steps to algorithm methodology. Discuss your algorithm design in relation to these four steps and describe how you went through each step of the methodology to create your algorithm.
Four steps to algorithm methodology are
1.Design
2.Analyse
3.Implement
4.Experiment
lets say our algorithm is find volume and lateral surface of a sphere given radius
Design:-The is to identify the problem and thoroughly understand it. problem is to find volume and lateral surface area of a sphere
Analyse:-Once you have the basic framework of the algorithm it’s time to start analyzing how efficient the code is in solving the problem.This is a step that some programmers like to attack after they have coded the algorithm and run it through the compiler. Others prefer to examine it prior to writing the code and analyze results based on their expectations from the design stage.
we have to think of efficiency of the problem
formula for voulume is
lateral surface area is
Implement:-Writing and coding the algorithm is the next step in the process
using namespace std;
#include<bits/stdc++.h>
int main(){
int r;
cin>>r;
float volume,surface_area;
volume=(4/3)*(22/7)*r*r*r;
surface_area=4*(22/7)*r*r;
cout<<volume<<endl;
cout<<surface_area<<endl;
return 0;
}
Experiment:-Once the algorithm is designed and coded go back and experiment with different variables in the algorithm. We have to check for different values and see the output we are getting right or wrong.