Answers.Body: <p>Any programming is a two step process: deciding how to solve the problem, then implementing that as code on a particular system: choosing or designing an algorithm is the first step.</p>
  
  <p>There are great ways to illustrate how the choice of algorithm <em>matters</em>. An introductory one might be search - comparing random, linear and binary algorithms to, for example, find a missing number, or a word in a (printed) dictionary, or a book in a (physical) library. </p>
  
  <p>Another might be exploring different sorting algorithms, for example bubble sort and quicksort using <a href="http://csunplugged.org/sorting-algorithms/" rel="nofollow noreferrer">this CS Unplugged activity</a>.</p>
  
  <p>Mathematics provides a rich source of contexts, for example asking students to think of an algorithm for finding the greatest common divisor (i.e. highest common factor) for a couple of numbers. Have them try their algorithms out on paper before coding them and then testing with some <em>big</em> test numbers. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T17:10:38.373Z
Answers.Text: This slightly compounds the misapprehension posed by the question that algorithms are only the special functions. So, your two step process is an algorithm (not a very useful one maybe). Honestly, I think the question is too general as it stands.
Answers.UserDisplayName: Sean Houlihane
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T17:54:31.463Z
Answers.Text: Algorithms as systematic, replicable, automatable ways to solve problems?
Answers.UserDisplayName: Miles
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T18:00:08.153Z
Answers.Text: Yes. Like a machine learning algorithm might be keep trying random stuff till you get a better result... Not just stuff that you find on github if you need to copy it (or have to memorise for an exam).
Answers.UserDisplayName: Sean Houlihane
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T16:21:03.983Z
Answers.LastActivityDate: 2017-05-24T16:21:03.983Z
Answers.UserDisplayName: Miles
Answers.Body: <p>A good way to talk about algorithms is as a series of simple steps that can be repeated. It's similar to the role of a function or routine. Here, everyday examples can be helpful, for example something like autocorrect. Autocorrect is a series of steps repeated over and over.</p>
  
  <ol>
  <li>Select the last word typed</li>
  <li>Check how similar it is to the other words that the computer knows</li>
  <li>Check how often the user has used each of these words</li>
  <li>Suggest the most similar and most used word</li>
  <li>If the user types a space, make the correction</li>
  </ol>
  
  <p>It will repeat these steps every time a character is typed. When writing code, it's clearly easier to write:</p>
  
  <pre><code>function check_last_word(text) {
    word = text.last_word
    similar_words = get_similar_words(dictionary, word)
    corrected_word = get_most_used_word(word_usage_data, similar_words)
    text = text - text.last_word + corrected_word
  }
  
  when text_is_changed? {
    check_last_word(text)
  }
  </code></pre>
  
  <p>As compared to:</p>
  
  <pre><code>word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  </code></pre>
  
  <p>And so on. This is not actually an example of an algorithm, but it acts as a good example to show why having a series of repeatable steps is better than simply going through each step each time.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T15:47:29.833Z
Answers.LastActivityDate: 2017-05-24T15:47:29.833Z
Answers.UserDisplayName: thesecretmaster
Answers.Body: <p>The importance of algorithms is that it is a form of automation. For example, calculating the Fibonacci Sequence would take a long to time to find n number, but if you create a program that finds that n number, you save a lot of time.</p>
  
  <p>Algorithms, used properly and with caution, can change your program from a 0 to a 100.</p>
  
  <p>You can think of an algorithm as a recipe that describes the exact steps needed for the computer to solve a problem or reach a goal. Your recipe would the procedure and the input would be inputs by the user. It's like a flowchart:</p>
  
  <p><a href="https://i.sstatic.net/nZeU0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nZeU0.png" alt="Flow chart"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T14:17:50.900Z
Answers.LastActivityDate: 2017-05-24T14:38:34.717Z
Answers.LastEditDate: 2017-05-24T14:38:34.717Z
Answers.UserDisplayName: Manav Dubey
Body: <p>Many computer science problems can be solved by more than one algorithm. Usually those algorithms have different problem-solving approaches and therefore different strengths and weaknesses.</p>
  
  <p>My impression is that some developers focus on choosing the most efficient algorithm when they are for example participating in programming competitions to increase their chances of winning, but this does not always translate to real world applications.</p>
  
  <p>Bad choices (e.g. always using bubble sort for a sorting operation instead of something more efficient) will eventually slow down the application.  But most of the time, what with computers being so fast, better choices don't seem to make a discernible difference.  How can we help teach developers that these choices ultimately do matter, and that they should aim for more efficient algorithms?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-14T23:45:06.527Z
Comments.Text: I've edited and re-opened the question.  A. Biswas, if I've modified your intention, feel free to roll back the edit.  (I tried to stick with what I believed you were asking)
Comments.UserDisplayName: Ben I.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-18T11:02:31.700Z
Comments.Text: The example given seems to me to correspond to a different question (how to explain to people the importance of using library functions rather than writing everything from scratch?)
Comments.UserDisplayName: Peter Taylor
Tags: <algorithms>
Title: How to explain to people the importance of algorithms in computer programming?
ThreadText: # How to explain to people the importance of algorithms in computer programming?
  
  (Asked by: username_0 on 2017-05-24)
  
  Many computer science problems can be solved by more than one algorithm. Usually those algorithms have different problem-solving approaches and therefore different strengths and weaknesses.
  
  My impression is that some developers focus on choosing the most efficient algorithm when they are for example participating in programming competitions to increase their chances of winning, but this does not always translate to real world applications.
  
  Bad choices (e.g. always using bubble sort for a sorting operation instead of something more efficient) will eventually slow down the application. But most of the time, what with computers being so fast, better choices don't seem to make a discernible difference. How can we help teach developers that these choices ultimately do matter, and that they should aim for more efficient algorithms?
  
  **Tags:** algorithms
  
  > **Comments:**
  > **username_1**: I've edited and re-opened the question.  A. username_0, if I've modified your intention, feel free to roll back the edit.  (I tried to stick with what I believed you were asking)  
  > **username_2**: The example given seems to me to correspond to a different question (how to explain to people the importance of using library functions rather than writing everything from scratch?)  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2017-05-24. Score: 3
  
  Any programming is a two step process: deciding how to solve the problem, then implementing that as code on a particular system: choosing or designing an algorithm is the first step.
  
  There are great ways to illustrate how the choice of algorithm *matters*. An introductory one might be search - comparing random, linear and binary algorithms to, for example, find a missing number, or a word in a (printed) dictionary, or a book in a (physical) library.
  
  Another might be exploring different sorting algorithms, for example bubble sort and quicksort using [this CS Unplugged activity](http://csunplugged.org/sorting-algorithms/).
  
  Mathematics provides a rich source of contexts, for example asking students to think of an algorithm for finding the greatest common divisor (i.e. highest common factor) for a couple of numbers. Have them try their algorithms out on paper before coding them and then testing with some *big* test numbers.
  
  > **Comments:**
  > **username_4**: This slightly compounds the misapprehension posed by the question that algorithms are only the special functions. So, your two step process is an algorithm (not a very useful one maybe). Honestly, I think the question is too general as it stands.  
  > **username_3**: Algorithms as systematic, replicable, automatable ways to solve problems?  
  > **username_4**: Yes. Like a machine learning algorithm might be keep trying random stuff till you get a better result... Not just stuff that you find on github if you need to copy it (or have to memorise for an exam).  
  
  ---
  
  ### Answer by username_5 on 2017-05-24. Score: 0
  
  A good way to talk about algorithms is as a series of simple steps that can be repeated. It's similar to the role of a function or routine. Here, everyday examples can be helpful, for example something like autocorrect. Autocorrect is a series of steps repeated over and over.
  
  1. Select the last word typed
  2. Check how similar it is to the other words that the computer knows
  3. Check how often the user has used each of these words
  4. Suggest the most similar and most used word
  5. If the user types a space, make the correction
  
  It will repeat these steps every time a character is typed. When writing code, it's clearly easier to write:
  
  ```
  function check_last_word(text) {
    word = text.last_word
    similar_words = get_similar_words(dictionary, word)
    corrected_word = get_most_used_word(word_usage_data, similar_words)
    text = text - text.last_word + corrected_word
  }
  
  when text_is_changed? {
    check_last_word(text)
  }
  
  ```
  
  As compared to:
  
  ```
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  word = text.last_word
  similar_words = get_similar_words(dictionary, word)
  corrected_word = get_most_used_word(word_usage_data, similar_words)
  text = text - text.last_word + corrected_word
  sleep until text_is_changed?
  
  ```
  
  And so on. This is not actually an example of an algorithm, but it acts as a good example to show why having a series of repeatable steps is better than simply going through each step each time.
  
  
  ---
  
  ### Answer by username_6 on 2017-05-24. Score: 0
  
  The importance of algorithms is that it is a form of automation. For example, calculating the Fibonacci Sequence would take a long to time to find n number, but if you create a program that finds that n number, you save a lot of time.
  
  Algorithms, used properly and with caution, can change your program from a 0 to a 100.
  
  You can think of an algorithm as a recipe that describes the exact steps needed for the computer to solve a problem or reach a goal. Your recipe would the procedure and the input would be inputs by the user. It's like a flowchart:
  
  [![Flow chart](https://i.sstatic.net/nZeU0.png)](https://i.sstatic.net/nZeU0.png)
  
  
  ---
  
  