Algorithms: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<center>
<blockquote style="padding: 5px; background-color: #FFF8DC; border: solid thin gray;">
  [[File:Exclamation.png]] This is an '''important concept'''.  You should fully understand this.
</blockquote>
</center>
[[File:computation.png|frame|right|This is a basic concept in computer science]]
[[File:computation.png|frame|right|This is a basic concept in computer science]]


Line 17: Line 11:
</html>
</html>


== Do you understand this ? ==
== Criteria for an algorithm ==
Below is an excellent criteria which defines what is an algorithm. It is used from this superb site: http://fiftyexamples.readthedocs.io/en/latest/algorithms.html<ref>http://fiftyexamples.readthedocs.io/en/latest/algorithms.html</ref>
* '''An algorithm is an unambiguous description''' that makes clear what has to be implemented. In a recipe, a step such as “Bake until done” is ambiguous because it doesn’t explain what “done” means. A more explicit description such as “Bake until the cheese begins to bubble” is better. In a computational algorithm, a step such as “Choose a large number” is vague: what is large? 1 million, 1 billion, or 100? Does the number have to be different each time, or can the same number be used on every run?
* '''An algorithm expects a defined set of inputs'''. For example, it might require two numbers where both numbers are greater than zero. Or it might require a word, or a list of zero or more numbers.
* '''An algorithm produces a defined set of outputs'''. It might output the larger of the two numbers, an all-uppercase version of a word, or a sorted version of the list of numbers.
* '''An algorithm is guaranteed to terminate and produce a result,''' always stopping after a finite time. If an algorithm could potentially run forever, it wouldn’t be very useful because you might never get an answer.
* '''Most algorithms are guaranteed to produce the correct result'''. It’s rarely useful if an algorithm returns the largest number 99% of the time, but 1% of the time the algorithm fails and returns the smallest number instead.
* '''If an algorithm imposes a requirement on its inputs (called a precondition), that requirement must be met'''. For example, a precondition might be that an algorithm will only accept positive numbers as an input. If preconditions aren’t met, then the algorithm is allowed to fail by producing the wrong answer or never terminating
.


== Standards ==  
== Standards ==  
These standards are used from the IB Computer Science Subject Guide<ref>IB Diploma Programme Computer science guide (first examinations 2014). Cardiff, Wales, United Kingdom: International Baccalaureate Organization. January 2012.</ref>


* Discuss an algorithm to solve a specific problem.
* Define algorithm
* Analyse an algorithm presented as a flow chart.
* Analyse an algorithm presented as pseudocode.
* Construct pseudocode to represent an algorithm.
* Suggest suitable algorithms to solve a specific problem.
* Deduce the efficiency of an algorithm in the context of its use.
* Determine the number of times a step in an algorithm will be performed for given input data
.
.



Latest revision as of 06:07, 1 October 2018

This is a basic concept in computer science

In mathematics and computer science, an algorithm is a self-contained step-by-step set of operations to be performed. Algorithms perform calculation, data processing, and/or automated reasoning tasks.[1]

Introduction[edit]

Content gratefully used with permission : [2]


Criteria for an algorithm[edit]

Below is an excellent criteria which defines what is an algorithm. It is used from this superb site: http://fiftyexamples.readthedocs.io/en/latest/algorithms.html[3]

  • An algorithm is an unambiguous description that makes clear what has to be implemented. In a recipe, a step such as “Bake until done” is ambiguous because it doesn’t explain what “done” means. A more explicit description such as “Bake until the cheese begins to bubble” is better. In a computational algorithm, a step such as “Choose a large number” is vague: what is large? 1 million, 1 billion, or 100? Does the number have to be different each time, or can the same number be used on every run?
  • An algorithm expects a defined set of inputs. For example, it might require two numbers where both numbers are greater than zero. Or it might require a word, or a list of zero or more numbers.
  • An algorithm produces a defined set of outputs. It might output the larger of the two numbers, an all-uppercase version of a word, or a sorted version of the list of numbers.
  • An algorithm is guaranteed to terminate and produce a result, always stopping after a finite time. If an algorithm could potentially run forever, it wouldn’t be very useful because you might never get an answer.
  • Most algorithms are guaranteed to produce the correct result. It’s rarely useful if an algorithm returns the largest number 99% of the time, but 1% of the time the algorithm fails and returns the smallest number instead.
  • If an algorithm imposes a requirement on its inputs (called a precondition), that requirement must be met. For example, a precondition might be that an algorithm will only accept positive numbers as an input. If preconditions aren’t met, then the algorithm is allowed to fail by producing the wrong answer or never terminating

.

Standards[edit]

  • Define algorithm

.

References[edit]