Systems in the Small: An Introduction to Algorithms David Millard (dem@ecs.soton.ac.uk)
Overview <ul><li>Definitions </li></ul><ul><li>Characteristics </li></ul><ul><li>Example Algorithm – Searching a List </li...
Definitions - Etymology <ul><li>Algorism (n) </li></ul><ul><li>Arab mathematician Abu Abdullah Muhammad ibn Musa  al-Khwar...
Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a sequence of finite instructions, ofte...
Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a  sequence  of finite instructions, of...
Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a  sequence  of  finite instructions , ...
Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a  sequence  of  finite instructions , ...
Characteristics of an Algorithm <ul><li>Performance </li></ul><ul><li>What else? </li></ul>
Characteristics of an Algorithm <ul><li>Performance </li></ul><ul><li>Efficiency </li></ul><ul><li>Understandability </li>...
An Example Algorithm <ul><li>Scenario: We have a list of things arranged in order (for example, people by Birthday). How m...
An Example Algorithm <ul><li>Brute Force : Ask the first person, if they are not the month we want ask the next person. Co...
An Example Algorithm <ul><li>Binary Search : Ask the middle person. If they are not the month we want then compare their m...
Complexity: Which is Best?
Complexity: Which is Best? <ul><li>Brute Force </li></ul><ul><ul><li>best– 1 </li></ul></ul><ul><ul><li>worst – n </li></u...
Complexity: Which is Best? <ul><li>Brute Force </li></ul><ul><ul><li>best– 1 </li></ul></ul><ul><ul><li>worst – n </li></u...
Assumptions <ul><li>A nice way to make life easier </li></ul><ul><ul><li>In our search example we assumed that the list wa...
An Algorithm to Change the World <ul><li>In 1996 two Standord PhD students (Larry Page and Sergey Brin) started looking at...
An Algorithm to Change the World <ul><li>In 1998 Larry and Sergey created a Web Search Engine called Google based on PageR...
Summary <ul><li>Algorithms are: </li></ul><ul><ul><li>A Sequence </li></ul></ul><ul><ul><li>…  of finite steps </li></ul><...
Break
Welcome Back <ul><li>In Binary Search our list was already in order </li></ul><ul><li>But what algorithm could create that...
Let’s Try Some Out
Examples of Sorting Algorithms <ul><li>Bubble Sort </li></ul><ul><ul><li>Swaps pairs of numbers repeatedly until no more l...
Examples of Sorting Algorithms <ul><li>Insertion Sort </li></ul><ul><ul><li>Creates a second ordered list by placing each ...
Examples of Sorting Algorithms <ul><li>Quick Sort </li></ul><ul><ul><li>Uses a pivot point </li></ul></ul><ul><ul><li>Reor...
Summary <ul><li>Algorithms are: </li></ul><ul><ul><li>A Sequence </li></ul></ul><ul><ul><li>…  of finite steps </li></ul><...
Upcoming SlideShare
Loading in …5
×

Systems in the small - Introduction to Algorithms

833 views

Published on

A brief presentation to introduce new IT students to the concept of algorithms - including some short group exercises based around search and sorting lists

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
833
On SlideShare
0
From Embeds
0
Number of Embeds
69
Actions
Shares
0
Downloads
54
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Systems in the small - Introduction to Algorithms

  1. 1. Systems in the Small: An Introduction to Algorithms David Millard (dem@ecs.soton.ac.uk)
  2. 2. Overview <ul><li>Definitions </li></ul><ul><li>Characteristics </li></ul><ul><li>Example Algorithm – Searching a List </li></ul><ul><li>Complexity </li></ul><ul><li>Assumptions </li></ul><ul><li>Algorithms that have Changed the World </li></ul><ul><li>Break </li></ul><ul><li>Activity: Building a Sorting Algorithm </li></ul>
  3. 3. Definitions - Etymology <ul><li>Algorism (n) </li></ul><ul><li>Arab mathematician Abu Abdullah Muhammad ibn Musa al-Khwarizmi (early 9th century) </li></ul><ul><li>Europe became aware of his work on Algebra </li></ul><ul><li>Arab numerals became associated with his name </li></ul><ul><li>Has since evolved to mean all processes for solving tasks </li></ul>
  4. 4. Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a sequence of finite instructions, often used for calculation and data processing…” </li></ul><ul><li>Wikipedia </li></ul><ul><li>&quot;A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.” </li></ul><ul><li>Answers.com </li></ul><ul><li>“ A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” </li></ul><ul><li>Merriam Webster Dictionary </li></ul>
  5. 5. Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a sequence of finite instructions, often used for calculation and data processing…” </li></ul><ul><li>Wikipedia </li></ul><ul><li>&quot;A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.” </li></ul><ul><li>Answers.com </li></ul><ul><li>“ A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” </li></ul><ul><li>Merriam Webster Dictionary </li></ul>
  6. 6. Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a sequence of finite instructions , often used for calculation and data processing…” </li></ul><ul><li>Wikipedia </li></ul><ul><li>&quot;A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps .” </li></ul><ul><li>Answers.com </li></ul><ul><li>“ A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” </li></ul><ul><li>Merriam Webster Dictionary </li></ul>
  7. 7. Definitions - Dictionary <ul><li>Algorithm (n) </li></ul><ul><li>“ An algorithm is a sequence of finite instructions , often used for calculation and data processing …” </li></ul><ul><li>Wikipedia </li></ul><ul><li>&quot;A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps .” </li></ul><ul><li>Answers.com </li></ul><ul><li>“ A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” </li></ul><ul><li>Merriam Webster Dictionary </li></ul>
  8. 8. Characteristics of an Algorithm <ul><li>Performance </li></ul><ul><li>What else? </li></ul>
  9. 9. Characteristics of an Algorithm <ul><li>Performance </li></ul><ul><li>Efficiency </li></ul><ul><li>Understandability </li></ul><ul><li>Scalability </li></ul><ul><li>Reusability </li></ul><ul><li>Reliability </li></ul><ul><li>Elegance </li></ul><ul><ul><li>Elegance (n). Of scientific processes, demonstrations, inventions, etc.: ‘Neatness’, ingenious simplicity, convenience, and effectiveness - OED </li></ul></ul>
  10. 10. An Example Algorithm <ul><li>Scenario: We have a list of things arranged in order (for example, people by Birthday). How might we find a given value (for example, a particular month)? </li></ul>
  11. 11. An Example Algorithm <ul><li>Brute Force : Ask the first person, if they are not the month we want ask the next person. Continue until we find the right month </li></ul>
  12. 12. An Example Algorithm <ul><li>Binary Search : Ask the middle person. If they are not the month we want then compare their month to our desired month. If it is earlier then discard them and everyone before them, if later discard them and everyone after them. Choose the new middle person and continue until we find the right month. </li></ul>
  13. 13. Complexity: Which is Best?
  14. 14. Complexity: Which is Best? <ul><li>Brute Force </li></ul><ul><ul><li>best– 1 </li></ul></ul><ul><ul><li>worst – n </li></ul></ul><ul><ul><ul><li>For 16 people worst = 16 </li></ul></ul></ul><ul><ul><li>O (n) </li></ul></ul>
  15. 15. Complexity: Which is Best? <ul><li>Brute Force </li></ul><ul><ul><li>best– 1 </li></ul></ul><ul><ul><li>worst – n </li></ul></ul><ul><ul><ul><li>For 16 people worst = 16 </li></ul></ul></ul><ul><ul><li>O (n) </li></ul></ul><ul><li>Binary Search </li></ul><ul><ul><li>best– 1 </li></ul></ul><ul><ul><li>worst – log 2 n </li></ul></ul><ul><ul><ul><li>For 16 people worst = 4 </li></ul></ul></ul><ul><ul><ul><li>2 x 2 x 2 x 2= 16 </li></ul></ul></ul><ul><ul><li>O (log 2 n) </li></ul></ul>
  16. 16. Assumptions <ul><li>A nice way to make life easier </li></ul><ul><ul><li>In our search example we assumed that the list was ordered </li></ul></ul><ul><ul><li>So we assumed that our values had order! </li></ul></ul><ul><ul><ul><li>(what about a list of animals, musical notes or colours) </li></ul></ul></ul><ul><li>Assumptions simplify problems </li></ul><ul><ul><ul><li>Assumptions must be realistic </li></ul></ul></ul><ul><ul><ul><li>Assumptions must be clearly stated </li></ul></ul></ul>
  17. 17. An Algorithm to Change the World <ul><li>In 1996 two Standord PhD students (Larry Page and Sergey Brin) started looking at the Web as a mathematical graph </li></ul><ul><li>They developed an algorithm called PageRank that evaluated the importance of each node in the graph according to its connections to other nodes </li></ul>
  18. 18. An Algorithm to Change the World <ul><li>In 1998 Larry and Sergey created a Web Search Engine called Google based on PageRank </li></ul><ul><li>Summer 2000 they had indexed 1 billion pages </li></ul><ul><li>August 2008 Google is valued at $ 157 billion </li></ul>
  19. 19. Summary <ul><li>Algorithms are: </li></ul><ul><ul><li>A Sequence </li></ul></ul><ul><ul><li>… of finite steps </li></ul></ul><ul><ul><li>… to solve a problem! </li></ul></ul><ul><li>They can be characterised in a number of different ways (performance, efficiency, reusability, etc.) </li></ul><ul><li>Complexity is a measure of how long an algorithm will take (or how many resources it might use) </li></ul><ul><li>And a good algorithm can change the world :-) </li></ul>
  20. 20. Break
  21. 21. Welcome Back <ul><li>In Binary Search our list was already in order </li></ul><ul><li>But what algorithm could create that order? </li></ul><ul><li>Get into groups of around 4 people </li></ul><ul><li>Create an Algorithm that could take an unordered list and return an ordered list (suitable for Binary search) </li></ul><ul><ul><li>Write down your algorithm using English </li></ul></ul><ul><ul><li>Try and be as unambiguous as possible </li></ul></ul>
  22. 22. Let’s Try Some Out
  23. 23. Examples of Sorting Algorithms <ul><li>Bubble Sort </li></ul><ul><ul><li>Swaps pairs of numbers repeatedly until no more left to swap </li></ul></ul>8 3 7 4 0 1 8 3 7 4 0 1 3 8 7 4 0 1 3 8 7 4 0 1 3 7 8 4 0 1
  24. 24. Examples of Sorting Algorithms <ul><li>Insertion Sort </li></ul><ul><ul><li>Creates a second ordered list by placing each element from the first list in turn </li></ul></ul>8 3 7 4 0 1 3 7 4 0 1 8 7 4 0 1 3 8 4 0 1 3 7 8 0 1 3 4 7 8 1 0 3 4 7 8 0 1 3 4 7 8
  25. 25. Examples of Sorting Algorithms <ul><li>Quick Sort </li></ul><ul><ul><li>Uses a pivot point </li></ul></ul><ul><ul><li>Reorders the list so that all elements with higher value are after the pivot and those with lower are before </li></ul></ul><ul><ul><li>Pivot is now in correct position, repeat for each side </li></ul></ul>8 3 7 4 0 1 8 3 7 4 0 1 3 0 1 4 8 7 3 0 1 4 8 7
  26. 26. Summary <ul><li>Algorithms are: </li></ul><ul><ul><li>A Sequence </li></ul></ul><ul><ul><li>… of finite steps </li></ul></ul><ul><ul><li>… to solve a problem </li></ul></ul><ul><li>They can be characterised in a number of different ways (performance, efficiency, reusability, etc.) </li></ul><ul><li>Complexity is a measure of how long an algorithm will take (or how many resources it might use) </li></ul><ul><li>And a good algorithm can change the world :-) </li></ul>

×