Chapter 1 Sections 1.1 – 1.4 pages 1-40. Homework  Read Section 1.4 (recap of data structures)  pages 26-37  Answer the following questions: page 38,

Slides:



Advertisements
Similar presentations
Algorithm Design Techniques
Advertisements

MATH 224 – Discrete Mathematics
5/15/2015COT COT 5407: Introduction to Algorithms Tao Li ECS 318; Phone: x6036
CS333 Algorithms
The Design & Analysis of the algorithms Lecture by me M. Sakalli.
Design and Analysis of Algorithms - Chapter 1
Design and Analysis of Algorithms - Chapter 31 Brute Force A straightforward approach usually based on problem statement and definitions Examples: 1. Computing.
Design and Analysis of Algorithms - Chapter 1
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.
Homework page 102 questions 1, 4, and 10 page 106 questions 4 and 5 page 111 question 1 page 119 question 9.
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.
Design and Analysis of Algorithms
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
Why study algorithms? Theoretical importance
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
Introduction to Algorithms Rabie A. Ramadan rabieramadan.org Some of the sides are exported from different sources to.
1 Decrease-and-Conquer Approach Lecture 06 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing.
CSCE350: Data Structures and Algorithms Instructor: Dr. Jianjun Hu Fall Department of Computer Science and Engineering.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Theory of Algorithms: Brute Force. Outline Examples Brute-Force String Matching Closest-Pair Convex-Hull Exhaustive Search brute-force strengths and weaknesses.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Design & Analysis of Algorithms Lecture 1 Introduction.
FIRST QUESTIONS FOR ALGORITHM ANALYSIS. WHAT IS AN ALGORITHM? From the text (p. 3): “An algorithm is a sequence of unambiguous instructions for solving.
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction.
Design and Analysis of Algorithms - Chapter 11 Algorithm b An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
Analysis of Algorithms COME 355 Introduction. What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e.,
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3 rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
LIMITATIONS OF ALGORITHM POWER
Computer Science/Ch. Algorithmic Foundation of CS 4-1 Chapter 4 Chapter 4 Algorithmic Foundation of Computer Science.
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin “ Introduction to the Design & Analysis of Algorithms, ” 2 nd ed., Ch. 1 Chapter.
Introduction to design and analysis algorithm
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Why do we study algorithms?. 2 First results are about bats and dolphins.
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Design and Analysis of Algorithms Faculty Name : Ruhi Fatima Course Description This course provides techniques to prove.
1 Introduction to design and analysis algorithm. 2.
Advanced Algorithms Analysis and Design
TK3043 Analysis and Design of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
The Design and Analysis of Algorithms
Decrease-and-Conquer Approach
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
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.
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.
Introduction to the Design and Analysis of Algorithms
Introduction to The Design & Analysis of Algorithms
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.
Courtsey & Copyright: DESIGN AND ANALYSIS OF ALGORITHMS Courtsey & Copyright:
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.
Design and Analysis of Computer Algorithm (CS575-01)
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
Objective of This Course
Chapter 11 Limitations of Algorithm Power
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
3. Brute Force Selection sort Brute-Force string matching
3. Brute Force Selection sort Brute-Force string matching
Algorithms Algorithm. [webster.com] A procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps.
Introduction to Algorithms
Design and Analysis of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
3. Brute Force Selection sort Brute-Force string matching
Welcome to the most Amazing course there is 
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.
Presentation transcript:

Chapter 1 Sections 1.1 – 1.4 pages 1-40

Homework  Read Section 1.4 (recap of data structures)  pages  Answer the following questions: page 38, questions 1a, 1b, 2a, 2b, & 10page 38, questions 1a, 1b, 2a, 2b, & 10 Also, what exactly is a dictionary (not Webster's)Also, what exactly is a dictionary (not Webster's) Due Wed 1/28 (in class)Due Wed 1/28 (in class)

Agenda  WTF?  Euclid’s algorithm  What is an algorithm  What is algorithm analysis all about  Problem types

Algorithm design & analysis process Understand the Problem Pick an algorithm design technique Pick data structures, etc. Design an algorithmAnalyze the algorithmProve correctnessCode the algorithm WTF?

Euclid’s Algorithm  while n != 0 do r  m mod n m  n n  r return m  Isn’t it a cool algorithm?  Its very efficient, no?  How many divisions must it do, as a function of m or n?

Euclid’s Algorithm  Best case: m mod n equal zero  Worst case? Prime numbers maybe?Prime numbers maybe? How do you get it to do a lot of divisions?How do you get it to do a lot of divisions?

Try This  Two prime numbers 29 and 7  Then try 13 and 8.  How can you cause the worst case?

Euclid’s Algorithm  Answer: Two consecutive Fibonacci numbers.  In the worst case it will require about L divisions where L is the total number of digits in both n and m.where L is the total number of digits in both n and m.  Proving this is not fun.  Lets not do it, OK?

Euclid’s Algorithm  If I have two 10 digit numbers, Euclid’s algorithm will take (at most) about 20 divisions.  Whereas, consecutive integer checking could take 9,999,999,999 X 2 divisions.  How does Euclid’s algorithm gain such an advantage?

Euclid’s Algorithm  r  m mod n  If r is not equal to zero then all the numbers between m and r are NOT gcd’s of m and n.  Its all about understanding the properties of the problem. What is the definition of a gcd?What is the definition of a gcd? What is the definition of mod?What is the definition of mod? The two are related.The two are related.

An Algorithm  A sequence of unambiguous instructions for solving a problem,  i.e., for obtaining a required output for any legitimate input  in a finite amount of time.

History Lesson  Muhammad ibn Musa al-Khwarizmi Famous mathematician from Bagdad 800 A.DFamous mathematician from Bagdad 800 A.D  He wrote Al-jabr wa'l muqabala (from which our modern word "algebra" comes)  The English word "algorithm" derives from the Latin form of al-Khwarizmi's name

Stupid, irrelevant, personal anecdote  As an undergraduate, I had Indian Professor who was an expert on algorithms and pronounced the word  A – grow – rid – em’s  Lets practice saying the word so we don’t sound like idiots.

Notion of algorithm “computer” problem algorithm inputoutput

Example of computational problem: sorting  Statement of problem: Input: A sequence of n numbers Input: A sequence of n numbers Output: A reordering of the input sequence so that a ´ i ≤ a ´ j whenever i so that a ´ i ≤ a ´ j whenever i < j  Instance: The sequence  Instance: The sequence  Algorithms: Selection sortSelection sort Insertion sortInsertion sort Merge sortMerge sort (many others)(many others)

Example  Input: array a[1],…,a[n]  Output: array a sorted in non-decreasing order  Algorithm: for i=1 to n for i=1 to n swap a[i] with smallest of a[i],…a[n] swap a[i] with smallest of a[i],…a[n]

Algorithm design strategies  Brute force  Divide and conquer  Decrease and conquer  Transform and conquer  Greedy approach  Dynamic programming  Backtracking and Branch and bound  Space and time tradeoffs

Analysis of Algorithms  How good is the algorithm? CorrectnessCorrectness Time efficiencyTime efficiency Space efficiencySpace efficiency  Does there exist a better algorithm? Lower boundsLower bounds OptimalityOptimality

Some Well-known Computational Problems  Sorting  Searching  Shortest paths in a graph  Minimum spanning tree  Primality testing  Traveling salesman problem  Knapsack problem  Chess  Towers of Hanoi  Program termination

Why do we care?  Sorting  Searching  Shortest paths in a graph  Minimum spanning tree  Primality testing  Traveling salesman problem  Knapsack problem  Chess  Towers of Hanoi  Program termination Variations of the solutions to these problems are used to…  Schedule flights  Route Internet traffic  Make Google work  Prevent the stock-market from crashing  Assemble the human genome  Encrypt data  Save UPS millions of dollars  Track terrorist cell communication on the Internet  Make spell checkers work  help keep you from going through the walls in games like Halo and CounterStrike

Basic Issues Related to Algorithms  How to design algorithms  How to express algorithms  Proving correctness  Efficiency Theoretical analysisTheoretical analysis Empirical analysis (experiments)Empirical analysis (experiments)  Optimality

What is an algorithm?  Recipe, process, method, technique, procedure, routine,… with following requirements: 1. Finiteness b terminates after a finite number of steps 2. Definiteness b rigorously and unambiguously specified 3. Input b valid inputs are clearly specified 4. Output b can be proved to produce the correct output given a valid input 5. Effectiveness b steps are sufficiently simple and basic

Why study algorithms?  Theoretical importance the core of computer sciencethe core of computer science  Practical importance A practitioner’s toolkit of known algorithmsA practitioner’s toolkit of known algorithms Framework for designing and analyzing algorithms for new problemsFramework for designing and analyzing algorithms for new problems

Important Types of Problems  Sorting & Searching  String matching & pattern matching  Graph Problems  Combinatorial Problems  Geometric Problems  Numerical Problems

Sorting & Searching  Intrinsically related Sorting can make searching easierSorting can make searching easier  sort key – an important attribute used to sort data  stable sort – preserves the relative order of any two equal elements  in place sorting – doesn’t require extra memory  search key – not necessarily unique

String matching & pattern matching  Amazingly well-studied  Surprisingly difficult problem for certain variations  Tons of applications: Approximate matching used in spell checkersApproximate matching used in spell checkers Pattern matching used to find genes in DNAPattern matching used to find genes in DNA Or, used to find patterns in the stock marketOr, used to find patterns in the stock market

Graph Problems  Graphs can be used to model all sorts of real-world environments, scenarios, and systems. Relationship modeling using graphs is very powerfulRelationship modeling using graphs is very powerful  Representing the real-world as a graph can allow computers to solve all sorts of problems.  Graph related algorithms are being used to detect terrorist cell communication via the Internet.  Hell, the Internet itself is a massive graph.

Combinatorial Problems  Certain problems, like optimal scheduling or routing, can be reduced to finding the optimal parameters among the set of all possible parameters  But, the number of different parameter combinations can become very large, too large.  Reducing the combinatorial space of problems is a very important strategy in algorithms

Geometric Problems  These problems can be as simple as finding the intersection point of two lines to  Finding the Delaunay Triangulation of the smallest convex polygon containing a given set of points.  These types of problems arise from modeling all sorts of real-world entities.

Numerical Problems  Problems involving mathematical objects  solving equations  computing integrals  efficiently evaluating functions  i.e., really boring stuff

Data Structures  The assigned reading is all about common data structures used in algorithms  Data structures are just one of many tools that can be used to improve algorithms  Perhaps they are the most important tool  Do the reading and homework  This material should not be new.

Homework  Read Section 1.4 (recap of data structures)  pages  Answer the following questions: page 38, questions 1a, 1b, 2a, 2b, & 10page 38, questions 1a, 1b, 2a, 2b, & 10 Also, what exactly is a dictionary (not Webster's)Also, what exactly is a dictionary (not Webster's) Due Wed 1/28 (in class)Due Wed 1/28 (in class)