2. Given below is an algorithm to make a sandwich. Read it and answer the questions<br />that follow<br />Step 1: Take the ingredients.<br />Step 2: Make a sandwich.<br />(a) Does the algorithm explain how a sandwich is made? If you have never made<br />sandwich before, will you be able to make one by following this algorithm?<br />(b) Is the algorithm a good algorithm or a bad algorithm? Give reason(s) for your<br />answer.
Answers
Answer:
a) No it does not.
b) We will not be able to make a sandwich after understanding the algorithm.
c) Bad algorithm, because a good algorithm contains specification of every detail. This algorithm should contain specifications of ingredients and the order.A better algorithm would be following.
1) Get a knife and 2 slices of bread
2) Spread butter on the slices of bread
3) Put a topping on one slice of bread
4) Put one slice of bread on the other and cut in half
Answer:
Concept:
An algorithm is a finite sequence of exact instructions that is used in mathematics and computer science to solve a class of particular problems or carry out a computation. For performing calculations and processing data, algorithms are employed as specifications.
Explanation:
An algorithm must assist us in solving a particular problem for it to be useful. Five properties must be met by an algorithm in order for something to happen.
- An algorithm's inputs must come from a predetermined set of components, where both the quantity and nature of the inputs are predetermined.
- The output and its relationship to the input must be specified by the algorithm.
- Clarity: The algorithm's steps must be precisely specified and described in detail.
- Effectiveness: The algorithm's steps must be manageable and efficient.
- Finiteness: After a predetermined number of steps, the algorithm must finish.
(a) Does the algorithm explain how a sandwich is made? If you have never made sandwich before, will you be able to make one by following this algorithm?
- No the algorithm does not clearly explains how a sandwich has to be made. Definitely with the given algorithm , no one can make sandwich.
(b) Is the algorithm a good algorithm or a bad algorithm? Give reason(s) for your answer.
- The given algorithm is a bad algorithm as it does not possess any of the properties defined for algorithm.
#SPJ2