Complexity, etc. Homework. Comparison to computability. Big Oh notation. Sorting. Classwork/Homework: prepare presentation on specific sorts. Presentation.

Slides:



Advertisements
Similar presentations
Deterministic Finite Automata (DFA)
Advertisements

Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Razdan with contribution from others 1 Algorithm Analysis What is the Big ‘O Bout? Anshuman Razdan Div of Computing.
Analysys & Complexity of Algorithms Big Oh Notation.
Computability Start complexity. Motivation by thinking about sorting. Homework: Finish examples.
Computational Complexity 1. Time Complexity 2. Space Complexity.
Chapter 1 – Basic Concepts
CS21 Decidability and Tractability
Computability and Complexity 22-1 Computability and Complexity Andrei Bulatov Hierarchy Theorem.
Analysis of Algorithms1 Estimate the running time Estimate the memory space required. Time and space depend on the input size.
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
Cmpt-225 Algorithm Efficiency.
3/10/03Tucker, Sec.3-51 Tucker, Applied Combinatorics, Sec. 3.5, Jo E-M “Big O” Notation We say that a function is if for some constant c, when n is large.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 i206: Lecture 6: Math Review, Begin Analysis of Algorithms Marti Hearst Spring 2012.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
1 Complexity Lecture Ref. Handout p
Time Complexity Dr. Jicheng Fu Department of Computer Science University of Central Oklahoma.
Algorithm Analysis & Complexity We saw that a linear search used n comparisons in the worst case (for an array of size n) and binary search had logn comparisons.
Program Performance & Asymptotic Notations CSE, POSTECH.
Lecture 2 Computational Complexity
Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Chapter 4. Algorithm Analysis (complexity)
Approximation Algorithms Pages ADVANCED TOPICS IN COMPLEXITY THEORY.
Analysis of Algorithms
Algorithm Evaluation. What’s an algorithm? a clearly specified set of simple instructions to be followed to solve a problem a way of doing something What.
Does not Compute 4: Finite Automata In which we temporarily admit defeat with cellular automata (we will face them again, in the epic final “Does Not Compute”
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
Asymptotic Notation (O, Ω, )
MS 101: Algorithms Instructor Neelima Gupta
Theory of Computing Lecture 21 MAS 714 Hartmut Klauck.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
3.3 Complexity of Algorithms
CMSC 341 Asymptotic Analysis. 2 Complexity How many resources will it take to solve a problem of a given size? –time –space Expressed as a function of.
Asymptotic Performance. Review: Asymptotic Performance Asymptotic performance: How does algorithm behave as the problem size gets very large? Running.
CS 203: Introduction to Formal Languages and Automata
Algorithms, Complexity and Sorting academy.zariba.com 1.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Hierarchy theorems Section 9.1 Giorgi Japaridze Theory of Computability.
Computer Science Background for Biologists CSC 487/687 Computing for Bioinformatics Fall 2005.
Algorithm Analysis: Running Time Big O and omega ( 
Searching Topics Sequential Search Binary Search.
CES 592 Theory of Software Systems B. Ravikumar (Ravi) Office: 124 Darwin Hall.
Computability O(n) exercises. Searching. Shuffling Homework: review examples. Research other shuffling.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
Chapter 9: Sorting1 Sorting & Searching Ch. # 9. Chapter 9: Sorting2 Chapter Outline  What is sorting and complexity of sorting  Different types of.
Sorting Algorithms Written by J.J. Shepherd. Sorting Review For each one of these sorting problems we are assuming ascending order so smallest to largest.
Computability Sort homework. Formal definitions of time complexity. Big 0. Homework: Exercises. Searching. Shuffling.
Algorithms Lecture #05 Uzair Ishtiaq. Asymptotic Notation.
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
1 Algorithms Searching and Sorting Algorithm Efficiency.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
Growth of Functions & Algorithms
Analysis of Algorithms
GC 211:Data Structures Algorithm Analysis Tools
HIERARCHY THEOREMS Hu Rui Prof. Takahashi laboratory
i206: Lecture 8: Sorting and Analysis of Algorithms
Algorithm design and Analysis
Complexity Present sorting methods. Binary search. Other measures.
Chapter 14 Time Complexity.
Analysys & Complexity of Algorithms
Advanced Analysis of Algorithms
Divide and Conquer Algorithms Part I
Time Complexity Lecture 14 Sec 10.4 Thu, Feb 22, 2007.
Time Complexity Lecture 15 Mon, Feb 27, 2006.
8. Comparison of Algorithms
Discrete Mathematics 7th edition, 2009
Presentation transcript:

Complexity, etc. Homework. Comparison to computability. Big Oh notation. Sorting. Classwork/Homework: prepare presentation on specific sorts. Presentation Day for some.

Homework CFG and PDA Regular expressions

Hierarchy There is a "proper" hierarchy concerning languages FSA and PDA and TM. meaning If a language is recognized by an FSA, then we can define a PDA. If a language is recognized by a PDA, we can define a TM. AND There are languages for which there is not FSA, but there is a PDA and similarly for PDA and TM.

Trick question Define a FSA for the language a i b j –some a's and then some b's. Define a FSA for the language a i b i –some a's and then the same number of b's.

Pumping lemma for FSA If A is a regular language, then there is a number p where if s is in A, and the length of s is at least p, then we can write s as s = xyz, –length of y is greater than 0 –length of xy is less than p and –xy i z is also in A. General idea: finite number of states. Set p to be number of states. So if there a string in A of length at least p, then the string s must re-visit at least 1 state. Call one such state q, then the substring from q and then back to q can be repeated.

Example of language that is not regular Alphabet {a,b}. All strings of the form a i b i –some number of a's followed by the same number of b's. –NOTE: the language of strings a i b j is regular.

Define a CFG for a i b j Try it!

Now, what about a i b i Write a grammar

Answer S => aSb S => ab Notice: this grammar is not regular. It better not be, because an application of the pumping lemma indicated that this language could not be produced by a FSA.

Many similar results Pumping lemma for CFL Extra credit assignment: look up and present to class.

Complexity calculate limit (maximum, minimum, worst case, average) amount of resources required to perform specific task –generally specific algorithm –time count of a specific type of operation –space Actual usage in any specific case may be different.

Comparison Computability looks at whether or not task can be done using a certain type of machine or grammar or definition of functions Complexity assumes that something can be done and complexity assessment generally looks at specific method –Note: there are proofs that say (something like) Any method will take at least …..

Bubble sort Class example Sort subset of students by height. Designate someone as counter of compare operations Designate someone as counter of swap operations Designate someone as counter of rounds

Bubble sort Worst case. n elements in set Round 1: n-1 compares Round 2: n-2 compares … Round n-1: 1 compare So, average number of compares per round is (n- 1)/2 Total number of compares is (rough) (n-1) * (n-1)/2

Measure generally given in terms of the size of the problem and given as a bound called Big Oh notation A function f(n) is O(g(n)), n integer, if there is an integer n 0 and a constant c such that f(n) =n 0 Conceptually, if n is big enough, than the function f is bounded by a multiple of the function g.

Common usage of O(n) O(c) constant O(n) linear O(n 2 ) quadratic O(n p ) polynomial O(n e ) exponential

Easy results f(n) = n IS O(n) and also O(n 2 ) and O(n p ) Let c = 1, and n 0 = 1, then n =1 but f(n 2 ) is NOT O(n)

Sorts There are sorting algorithms that are better than bubble sort, that is, time is less than O(n 2 ) heap sort quick sort merge sort Assign: be able to demonstrate with a deck of cards. Sketch proof on complexity.