Algorithms. Homework None – Lectures & Homework Solutions: https://jshare.johnshopkins.edu/kchurch4/public_html/teaching/103/ – Video:

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Prepare for next time No need to buy the book – Free online at Read Chapter 1 –
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
Programming Languages Wrap-up. Your Toolkit Object-oriented Imperative Functional Logic.
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
Symbolic Processing. How to Teach “Programming” Lecture 1: Education for kids – Lego Mindstorms (NQC: Not.
Search and Recursion pt. 2 CS221 – 2/25/09. How to Implement Binary Search Take a sorted data-set to search and a key to search for Start at the mid-point.
Scott Grissom, copyright 2004 Chapter 5 Slide 1 Analysis of Algorithms (Ch 5) Chapter 5 focuses on: algorithm analysis searching algorithms sorting algorithms.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Course Introduction CS 1037 Fundamentals of Computer Science II.
Finite state automaton (FSA)
Linear Bounded Automata LBAs
CS 280 Data Structures Professor John Peterson. Lexer Project Questions? Must be in by Friday – solutions will be posted after class The next project.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
Fall 2003Costas Busch - RPI1 Turing Machines (TMs) Linear Bounded Automata (LBAs)
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
NLTK (Natural Language Tool Kit) Unix for Poets (without Unix) Unix  Python.
FUNDAMENTALS OF PRACTICAL COMPUTING Ken ChurchFUNDAMENTALS OF PRACTICAL COMPUTING Ken Church Intended audience: – Students considering a major.
CPSC 388 – Compiler Design and Construction Parsers – Context Free Grammars.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 12 CS2110 – Fall 2009.
Formal Language Theory. Homework Read documentation on Graphviz – –
Chapter 12 Recursion, Complexity, and Searching and Sorting
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
Searching CS 105 See Section 14.6 of Horstmann text.
CSC 221: Recursion. Recursion: Definition Function that solves a problem by relying on itself to compute the correct solution for a smaller version of.
CSE 311 Foundations of Computing I Lecture 17 Structural Induction Spring
Saeid Pashzadeh Jan 2009 Theory of Computation 1.
Announcements Course evaluation Your opinion matters! Attendance grades Will be posted prior to the final Project 5 grades Will be posted prior to the.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
Foundations of Algorithms, Fourth Edition
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T W O Syntax.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Algorithms.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
Why Study Automata? What the Course is About Administrivia 1 Welcome to CSE309.
Transparency No. 1 Formal Language and Automata Theory Homework 5.
Lecture 2 What is a computational problem? What is an instance of a problem? What is an algorithm? How to guarantee that an algorithm is correct? What.
1/4 CALCULATING PREFIX SUMS Vladimir Jocovi ć 2012/0011.
Principles of Imperative Computation Lecture 1 January 15 th, 2012.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
C Sc 132 Computing Theory Professor Meiliu Lu Computer Science Department.
How to Teach “Programming” Lecture 1: Education for kids – Lego Mindstorms (NQC: Not Quite C)NQC – Scratch.
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Spring
Mid-Terms Exam Scope and Introduction. Format Grades: 100 points -> 20% in the final grade Multiple Choice Questions –8 questions, 7 points each Short.
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Autumn 2012 CSE
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Lecture #3 Analysis of Recursive Algorithms
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 20 Context-Free Grammars and Languages Autumn 2012 CSE
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Computability. Turing Machines Read input letter & tape letter, write tape letter, move left or right.
Theory of Computation. Introduction to The Course Lectures: Room ( Sun. & Tue.: 8 am – 9:30 am) Instructor: Dr. Ayman Srour (Ph.D. in Computer Science).
“<Fill in your definition here.>”
Analysis of Algorithms
Analysis of Algorithms
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
MA/CSSE 473 Day 02 Some Numeric Algorithms and their Analysis
Formal Language Theory
Course 2 Introduction to Formal Languages and Automata Theory (part 2)
CSE322 Chomsky classification
C H A P T E R T W O Syntax.
Analysis of Algorithms
Searching, Sorting, and Asymptotic Complexity
Analysis of Algorithms
Presentation transcript:

Algorithms

Homework None – Lectures & Homework Solutions: – Video: 046JFall-2005/VideoLectures/detail/embed03.htm 046JFall-2005/VideoLectures/detail/embed03.htm Next Week: Mid-Term – Open everything: book / laptop / notes / network

Old Business

CFGs: Context Free Grammars (Ch8)

Ambiguity

The Chomsky Hierarchy – Type 0 > Type 1 > Type 2 > Type 3 – Recursively Enumerable > CS > CF > Regular Examples – Type 3: Regular (Finite State): Grep & Regular Expressions Right-Branching: A  a A Left-Branching: B  B b – Type 2: Context-Free (CF): Center-Embedding: C  …  x C y Parenthesis Grammars:  ( ) w w R – Type 1: Context-Sensitive (CS): w w – Type 0: Recursively Enumerable – Beyond Type 0: Halting Problem

New Business

Hash Tables n steps Linear Time Constant Time n 2 time n time

Profiling

O(n) << O(n 2 ) Time n = |words|

Excel nslowfast 1, , , ,

Group Problems by Time Bounds log(n) – Binary Search, Fibonacci n – tr, cat, cut, uniq, egrep n log n – Sort n 2 – Edit Distance ( n 3 – Matrix Multiplication n – Context-Free Parsing 2 n – Factoring – Satisfiability

Summary (for Mid-Term) Symbolic Processing v. Stat Packages – Practical Symbolic: LISP, Wolfram Alpha Stats: Newton’s Method, R – Fundamental Stuff you can’t do with stat packages LISP: Recursion, Eval, Symbolic Differentiation Lambda Calculus – Small is Beautiful (beyond reason) – Church’s Thesis & Computability Theory

Summary (continued) Unix for Poets – Pipes: tr | sort | uniq –c Python & NLTK – Unix for Poets (without Unix) – Objects – Polymorphism – Equivalence Classes – Partial Orders Algorithms – Group problems by time & space bounds

Introduction to Programming Traditional (Start with Definitions) Constants: 1 Variables: x Objects: – lists, strings, arrays, matrices Expressions: x == 1 Statements: Side Effects – x = 1 (assignment) Conditionals: – If (x<=1) return 1; Iteration: for loops Functions Recursion Streams Non-Traditional (Start with Examples) Recursion def fact(x): if(x <= 1): return 1 else: return x * fact(x-1) Streams: – Unix Pipes Briefly mentioned – Everything else

Examples Factorial Fibonacci Counting Words in a Text

Python def fact(x): if(x <= 1): return 1 else: return x * fact(x-1) def fact2(x): result=1 for i in range(x): result *=(i+1); return result Recursion Iteration

Out-takes

Cosine Distance

Inner Products

Inner Product in Python def bag_of_words(words): D = {} for w in words: if(D.has_key(w)): D[w] = D[w] + 1; else: D[w]=1; return D def inner_product(D1,D2): sum = 0.0 for key in D1: if key in D2: sum += D1[key] * D2[key] return sum