CLSR says that an algorithm is a "well defined procedure".What exactly is meant by "well defined". Does it mean that it should not be ambiguous or non deterministic. If yes what could be meant by an algorithm being ambiguous or non deterministic.
1 Answers
A 'well defined procedure' just means that it should contain a series of steps that deal with every possible input variation.
for example, in a decision tree, you need to account for all cases till you reach the leaf. Take the example of an algorithm that finds the maximum of a list:
What should it do when you encounter only integers? How do you compare them? What happens if you try to compare two elements in the array which are not of the same type? Is there a restriction on the values that the elements in the array can take? What about the size of the array?
As such, you can find a ton of other questions along these lines. Algorithms need to be able to answer all of them and as such are 'well defined'.
non-deterministic algorithms is actually a very big field in CS. Look at this wikipedia link for more examples Non-deterministic algorithms. These algorithms can generate a different output for the same input in subsequent runs. For example something that uses a coin-flip to print "Heads" or "Tails". As such, based on your random number, the output will change across multiple runs.
Compare this to deterministic algorithms which produce the same output for the same input every single time

- 248
- 2
- 9