Question

In: Statistics and Probability

What is an algorithm? Give 2 examples of algorithms and explain what they do and how...

What is an algorithm? Give 2 examples of algorithms and explain what they do and how they work.

Solutions

Expert Solution

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:

  1. Get sandwich ingredients
  2. If at least one ingredient is missing.
    1. Get ingredient(s) at the store
  3. Place two slices of bread on the counter
  4. Get spreading knife
  5. Apply peanut butter to both the bread slices
  6. Place applied sides of bread together
  7. Eat 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.


Related Solutions

Explain: Analysis of algorithms with the example. Explain with example: How computational time of an algorithm...
Explain: Analysis of algorithms with the example. Explain with example: How computational time of an algorithm depends on input size? Write an algorithm (using whatever method you prefer) that takes an input of 10 integers, sorts the integers in ascending order and out puts the sorted list. In relation to computational time of your algorithm for part 4, what arrangement of the input numbers will cause the best case computational time? What arrangement will cause the worst case time?
What are Algorithms? Give an example
What are Algorithms? Give an example
Design and analysis of Algorithms: How do I write a k way merge sort algorithm from...
Design and analysis of Algorithms: How do I write a k way merge sort algorithm from a merge sort algorithm that splits 2 arrays while sorting?
How do you choose the correct graph type? Explain and give examples?
How do you choose the correct graph type? Explain and give examples?
Explain what SYSTEMIC RISK is. & give real life examples. provide 2 examples and use at...
Explain what SYSTEMIC RISK is. & give real life examples. provide 2 examples and use at least 4 lines. ECON MONEY AND BANKING CLASS
What do you understand by " hydrated ions" ? Give examples of hydrated ions and explain...
What do you understand by " hydrated ions" ? Give examples of hydrated ions and explain at least one hydrated ion's sturcture and formation.
1. Give examples of a personalized medicine. 2. What is Biomarker and how can it be...
1. Give examples of a personalized medicine. 2. What is Biomarker and how can it be used to identify cancer cells? 3 How are chemical compound libraries related to high throughput screening . 4. What is the value of Microarray technology? 4. How does DNA synthesizer make Oligonucleotides 5. Of what value are Oligonucleotides? 6. What are the three uses of peptides in medicinal biotechnology ? 7. How does pharmacogenetics allow for the development of personalized medicines?
1. What are some examples of administrative departments? 2. What is a Headcount Forecast Algorithm and...
1. What are some examples of administrative departments? 2. What is a Headcount Forecast Algorithm and what is its primary use? 3. Why is historically information particularly useful in creating a General and Administrative Cost budget?
Explain sensory adaptation. Give 2 examples of sensations that adapt quickly. What is an example of...
Explain sensory adaptation. Give 2 examples of sensations that adapt quickly. What is an example of a slow adapting sense and why is this?
2. Discuss how to mitigate the risks. Give examples.
2. Discuss how to mitigate the risks. Give examples.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT