In: Statistics and Probability
What is an algorithm? Give 2 examples of algorithms and explain what they do and how they work.
Algorithm : It is a step by step method of solving a problem based on conducting a sequence of specified actions.
In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.In a non-technical approach, we use algorithms in everyday tasks, such as a recipe to bake a cake or a manual to use a machine.
Example 1 :
To make a cheese sandwich:
Example 2 :
Input : lets assume we have a string of numbers ( positive and negative )
Output : we need a string with just the magnitude ( only positive )
1. get input
2. If number is positive take it in the output string
3. If number is negative multiply by -1
4. Get the resultant number in the output string.