Systems in the Small: An Introduction to Algorithms David Millard

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

MATH 224 – Discrete Mathematics
David Luebke 1 4/22/2015 CS 332: Algorithms Quicksort.
Searching Algorithms Finding what you are looking for.
COEN 352 Data structures and Algorithms R. Dssouli.
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Algorithm An algorithm is a step-by-step set of operations to be performed. Real-life example: a recipe Computer science example: determining the mode.
Ver. 1.0 Session 5 Data Structures and Algorithms Objectives In this session, you will learn to: Sort data by using quick sort Sort data by using merge.
CSE115/ENGR160 Discrete Mathematics 02/24/11 Ming-Hsuan Yang UC Merced 1.
Searching and Sorting SLA Computer Science 4/16/08 Allison Mishkin.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
The Design and Analysis of Algorithms
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
The Fundamentals: Algorithms, the Integers & Matrices.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
CIS 068 Welcome to CIS 068 ! Lesson 9: Sorting. CIS 068 Overview Algorithmic Description and Analysis of Selection Sort Bubble Sort Insertion Sort Merge.
Algorithms and their Applications CS2004 ( ) Dr Stephen Swift 1.2 Introduction to Algorithms.
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
Chapter 12 Recursion, Complexity, and Searching and Sorting
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 19: Searching and Sorting Algorithms.
ดร.สุรศักดิ์ มังสิงห์ SPU, Computer Science Dept.
September 29, Algorithms and Data Structures Lecture V Simonas Šaltenis Aalborg University
Design & Analysis of Algorithms Lecture 1 Introduction.
New Mexico Computer Science For All Algorithm Analysis Maureen Psaila-Dombrowski.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
CS261 Data Structures Ordered Bag Dynamic Array Implementation.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
Chapter 9 Sorting. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step is.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
ArrayList is a class that implements the List interface. The List interface is a blueprint for its “implementor” classes. There is another implementor.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
Sorting & Searching Geletaw S (MSC, MCITP). Objectives At the end of this session the students should be able to: – Design and implement the following.
CMPT 120 Topic: Searching – Part 2 and Intro to Time Complexity (Algorithm Analysis)
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
1.  A step by step process to solve any problem is called algorithm.  Algorithm is a process which take some values as input and provide us output.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
INTRO2CS Tirgul 8 1. Searching and Sorting  Tips for debugging  Binary search  Sorting algorithms:  Bogo sort  Bubble sort  Quick sort and maybe.
Comp1004: Programming in Java II Computational Thinking.
Algorithms 1: Sequences and Modules Yvonne Howard & Rikki Prince
ME 171 Computer Programming Language
Searching and Sorting Algorithms
Applied Discrete Mathematics Week 2: Functions and Sequences
TK3043 Analysis and Design of Algorithms
The Design and Analysis of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Teach A level Computing: Algorithms and Data Structures
Enough Mathematical Appetizers!
Sorting Data are arranged according to their values.
Binary Search Back in the days when phone numbers weren’t stored in cell phones, you might have actually had to look them up in a phonebook. How did you.
Algorithms Chapter 3 With Question/Answer Animations
Unit-2 Divide and Conquer
Comp1202: Building Better Programs
Welcome to CIS 068 ! Lesson 9: Sorting CIS 068.
Sorting Data are arranged according to their values.
Applied Discrete Mathematics Week 6: Computation
Principles of Computing – UFCFA3-30-1
Data Structures and Algorithms CSE 465
Algorithms Algorithm. [webster.com] A procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps.
Algorithm: Word comes from Arabic Author Abū ‘Abdallāh Muḥammad ibn Mūsā al-Khwārizmī Algorism Algebra: Kitab al-Mukhtasar fi Hisab al-Jabr wal-Muqabala.
Discrete Mathematics CS 2610
Divide and Conquer Merge sort and quick sort Binary search
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Welcome to the most Amazing course there is 
Presentation transcript:

Systems in the Small: An Introduction to Algorithms David Millard

Overview Definitions Characteristics Example Algorithm – Searching a List Complexity Assumptions Algorithms that have Changed the World Break Activity: Building a Sorting Algorithm

Definitions - Etymology Algorism (n) Arab mathematician Abu Abdullah Muhammad ibn Musa al-Khwarizmi (early 9th century) Europe became aware of his work on Algebra Arab numerals became associated with his name Has since evolved to mean all processes for solving tasks

Definitions - Dictionary Algorithm (n) “An algorithm is a sequence of finite instructions, often used for calculation and data processing…” Wikipedia "A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.” Answers.com “A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” Merriam Webster Dictionary

Definitions - Dictionary Algorithm (n) “An algorithm is a sequence of finite instructions, often used for calculation and data processing…” Wikipedia "A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.” Answers.com “A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” Merriam Webster Dictionary

Definitions - Dictionary Algorithm (n) “An algorithm is a sequence of finite instructions, often used for calculation and data processing…” Wikipedia "A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.” Answers.com “A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” Merriam Webster Dictionary

Definitions - Dictionary Algorithm (n) “An algorithm is a sequence of finite instructions, often used for calculation and data processing…” Wikipedia "A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.” Answers.com “A step-by-step procedure for solving a problem or accomplishing some end especially by a computer” Merriam Webster Dictionary

Characteristics of an Algorithm Performance What else?

Characteristics of an Algorithm Performance Efficiency Understandability Scalability Reusability Reliability Elegance ▫Elegance (n). Of scientific processes, demonstrations, inventions, etc.: ‘Neatness’, ingenious simplicity, convenience, and effectiveness - OED

An Example Algorithm 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)?

An Example Algorithm 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

An Example Algorithm 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.

Complexity: Which is Best?

Brute Force ▫best– 1 ▫worst – n  For 16 people worst = 16 ▫O (n)

Complexity: Which is Best? Brute Force ▫best– 1 ▫worst – n  For 16 people worst = 16 ▫O (n) Binary Search ▫best– 1 ▫worst – log 2 n  For 16 people worst = 4  2 x 2 x 2 x 2= 16 ▫O (log 2 n)

Assumptions A nice way to make life easier ▫In our search example we assumed that the list was ordered ▫So we assumed that our values had order!  (what about a list of animals, musical notes or colours) Assumptions simplify problems  Assumptions must be realistic  Assumptions must be clearly stated

An Algorithm to Change the World In 1996 two Standord PhD students (Larry Page and Sergey Brin) started looking at the Web as a mathematical graph They developed an algorithm called PageRank that evaluated the importance of each node in the graph according to its connections to other nodes

An Algorithm to Change the World In 1998 Larry and Sergey created a Web Search Engine called Google based on PageRank Summer 2000 they had indexed 1 billion pages August 2008 Google is valued at $ 157 billion

Summary Algorithms are: ▫A Sequence ▫… of finite steps ▫… to solve a problem! They can be characterised in a number of different ways (performance, efficiency, reusability, etc.) Complexity is a measure of how long an algorithm will take (or how many resources it might use) And a good algorithm can change the world :-)

Break

Welcome Back In Binary Search our list was already in order But what algorithm could create that order? Get into groups of around 4 people Create an Algorithm that could take an unordered list and return an ordered list (suitable for Binary search) ▫Write down your algorithm using English ▫Try and be as unambiguous as possible

Let’s Try Some Out

Examples of Sorting Algorithms Bubble Sort ▫Swaps pairs of numbers repeatedly until no more left to swap

Examples of Sorting Algorithms Insertion Sort ▫Creates a second ordered list by placing each element from the first list in turn

Examples of Sorting Algorithms Quick Sort ▫Uses a pivot point ▫Reorders the list so that all elements with higher value are after the pivot and those with lower are before ▫Pivot is now in correct position, repeat for each side

Summary Algorithms are: ▫A Sequence ▫… of finite steps ▫… to solve a problem They can be characterised in a number of different ways (performance, efficiency, reusability, etc.) Complexity is a measure of how long an algorithm will take (or how many resources it might use) And a good algorithm can change the world :-)