6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x))))

Size: px
Start display at page:

Download "6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x))))"

Transcription

1 September? 600-Introduction Trevor Darrell -D web page: section web page: Abstractions Pairs and lists Common list operations Procedural abstraction example: sqrt To find an approximation of square root of x: Make a guess G Improve the guess by averaging G and x/g Keep improving the guess until it is good enough (define try (lambda (guess x (if (good-enuf? guess x guess (define improve (lambda (guess x (try (improve guess x x (average guess (/ x guess (define average (lambda (a b (/ (+ a b (define good-enuf? (lambda (guess x (define sqrt (lambda (x (try x (< (abs (- (square guess x 0.00 The universe of procedures for sqrt average try improve Good-enuf? sqrt sqrt - Block Structure (define sqrt (lambda (x (define good-enuf? (lambda (guess (< (abs (- (square guess x 0.00 (define improve (lambda (guess (average guess (/ x guess (define sqrt-iter (lambda (guess (if (good-enuf? guess guess (sqrt-iter (improve guess (sqrt-iter.0 sqrt x: number good-enuf? improve x: number sqrt-iter 4 Pairs (cons cells (cons <x-exp> <y-exp> ==> <P> ;type: x, x Where <x-exp> evaluates to a value <x-val>, and <y-exp> evaluates to a value <y-val> Returns a pair <P> whose car-part is <x-val> and whose cdr-part is <y-val> (car <P> ==> <x-val> ;type: Pair Returns the car-part of the pair <P> (cdr <P> ==> <y-val> ;type: Pair Returns the cdr-part of the pair <P> Pair type of car part type of cdr part Pair - Box and pointer diagram (define p (cons <el> <el> p <el> (car p (cdr p <el> 5 6

2 Lists - Box and pointer diagram (cons <el> (cons <el> Printed representation (define x (list (define y (list (list (list (define z (list x x <el> <el> X == ( (list <el> <el>... <eln> Y == (( ( Z == (( ( <el> <el> <eln> 7 8 Cons, car, cdr (define thing (cons (cons (cons (cons thing ==> (( (cons ==> ( (cons (cons ==> ( (car thing ==> ( (cdr thing ==> ( (car (car thing ==> (car (cdr (cdr thing ==> List drill (car (cons (+ (- 4 ==> (cdr 6 ==> error (cdr (car (cons (cons (cons 4 (pair? #t ==> #f (pair? (car (cons ==> #f (pair? (cons (+ (car (cons ( 4 ==> #t 9 0 Length of a list cdr ing down a list (define (length lst (if (null? lst 0 (+ (length (cdr lst (define (list-ref lst n (if (= n 0 (car lst (list-ref (cdr lst (- n

3 More list drill More list drill x => (( y => ( z => ( ( ((4 w => ( 4 5 x => (( y => ( z => ( ( ((4 w => ( 4 5 (length x (length y (length z (list-ref z (append x y (cons x y (length x (length y (length z (list-ref z ((4 (append x y (( (cons x y ((( 4 Orders of Growth Orders of Growth What is the order of growth of last-k? (define (last-k k lst (if (= (length lst k lst (last-k k (cdr lst What is the order of growth of last-k? (define (last-k k lst (if (= (length lst k lst (last-k k (cdr lst Θ( n 5 6 The procedure copy-some that copies the first n elements of a list (copy-some (list 4 5 ==> ( (define (copy-some n list The procedure copy-some that copies the first n elements of a list (copy-some (list 4 5 ==> ( (define (copy-some n list (if (= n 0 (cons (car lst (copy-some (- n (cdr lst 7 8

4 (repeat x m returns a list containing the value x repeated m times. For example: (repeat 5 => (5 5 5 (repeat (list => (( ( Recursive solution: (define (repeat x m (if (= m 0 (cons x (repeat x (- m time (m space (m Iterative solution: (define (repeat x m (define (helper i answer (if (> i m answer (helper (+ i (cons x answer (helper 0 time (m space ( 9 0 (append lst lst appends lst to the end of lst. E.g.: (append (list 0 (list 4 => (0 4 (append (list 5 6 => (5 6 Recursive solution: (define (append lst lst (if (null? lst lst (cons (car lst (append (cdr lst lst time (n, space (n where n=(length lst Notice that only lst affects the time and space growth. Why doesn't lst matter? (reverse lst reverses lst. E.g.: (reverse (list 0 => ( 0 (reverse (list (list 5 (list 4 => (( 4 ( 5 Recursive solution: (define (reverse lst (if (null? lst (append (reverse (cdr lst (list (car l time (n^, since append runs in linear time ( (m where m=(length answer, each successive call to append takes more and more time: n = (n^. space (n, where n=(length lst Iterative solution: (define (reverse lst (define (helper rest answer (if (null? rest answer (helper (cdr rest (cons (car rest answer (helper lst time (n^, space (, where n=(length lst 4 4

5 (num-leaves tree returns the number of leaves in a tree, where a leaf is anything that isn't a list (number, string, boolean, procedure. E.g.: (num-leaves (list 0 (list 5 (list (list 4 => 6 (define (num-leaves tree (cond ((null? tree 0 ((pair? tree (+ (num-leaves (car tree (num-leaves (cdr tree (else time (n, space (d, where n is the number of pairs in the tree, and d is the depth of the tree. (num-leaves (list (list (list (list => Remember calendar 7 5

6.001 Recitation 22: Streams

6.001 Recitation 22: Streams 6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris

More information

Solutions to EoPL3 Exercises

Solutions to EoPL3 Exercises Solutions to EoPL3 Exercises Release 0.1.0 Cheng Lian May 16, 2017 Contents 1 Contents 3 2 Overview 29 i ii Author Cheng Lian Contents 1 2 Contents CHAPTER 1 Contents Chapter 1.

More information

6.001, Fall Semester, 1998 Problem Set 5 2 (define (adjoin-term term series) (cons-stream term series) Since this does not produce an error, he shows

6.001, Fall Semester, 1998 Problem Set 5 2 (define (adjoin-term term series) (cons-stream term series) Since this does not produce an error, he shows 1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 1998 Issued: Thursday, October 15,

More information

Meta-programming & you

Meta-programming & you Meta-programming & you Robin Message Cambridge Programming Research Group 10 th May 2010 What s meta-programming about? 1 result=somedb. customers. select 2 { first_name+ +last_name } 3 where name LIKE

More information

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee Algorithm Analysis Recurrence Relation Chung-Ang University, Jaesung Lee Recursion 2 Recursion 3 Recursion in Real-world Fibonacci sequence = + Initial conditions: = 0 and = 1. = + = + = + 0, 1, 1, 2,

More information

Recursion - 1. Recursion. Recursion - 2. A Simple Recursive Example

Recursion - 1. Recursion. Recursion - 2. A Simple Recursive Example Recursion - 1 Only looping method in pure Lisp is recursion Recursion Based on Chapter 6 of Wilensky Recursive function f includes calls to f in its definition For a recursive function to eventually terminate

More information

Assignment 4 - Solution

Assignment 4 - Solution Assignment 4 - Solution Question 1 // The key point to take into account is that the values can be obtained from the promises // in any order but we still want to resolve an array of values where all the

More information

Methods for solving recurrences

Methods for solving recurrences Methods for solving recurrences Analyzing the complexity of mergesort The merge function Consider the following implementation: 1 int merge ( int v1, int n1, int v, int n ) { 3 int r = malloc ( ( n1+n

More information

Lazy Multivariate Higher-Order Forward-Mode AD

Lazy Multivariate Higher-Order Forward-Mode AD To appear in POPL 2007 Lazy Multivariate Higher-Order Forward-Mode AD Barak A. Pearlmutter Hamilton Institute NUI Maynooth, Ireland barak@cs.nuim.ie Jeffrey Mark Siskind School of Electrical and Computer

More information

COMP Assignment 1 Solutions

COMP Assignment 1 Solutions COMP 409 - Assignment 1 Solutions 1 Show that there are no formulas of length 2,3, or 6, but that every other length is possible. Let p, q and r be atomic propositions. Then p is a formula of length 1,

More information

Recurrence Relations and Recursion: MATH 180

Recurrence Relations and Recursion: MATH 180 Recurrence Relations and Recursion: MATH 180 1: Recursively Defined Sequences Example 1: The sequence a 1,a 2,a 3,... can be defined recursively as follows: (1) For all integers k 2, a k = a k 1 + 1 (2)

More information

Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections , 3.2, , 4.7.2)

Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections , 3.2, , 4.7.2) Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections 1.1-1.7, 3.2, 3.4.1-3.4.2, 4.7.2) Carlos Varela RPI September 9, 2016 Adapted with permission from: Seif Haridi KTH

More information

Binary Search Trees. Motivation

Binary Search Trees. Motivation Binary Search Trees Motivation Searching for a particular record in an unordered list takes O(n), too slow for large lists (databases) If the list is ordered, can use an array implementation and use binary

More information

Meta-Circularity, and Vice-Versa

Meta-Circularity, and Vice-Versa 1/60, and Vice-Versa didier@lrde.epita.fr http://www.lrde.epita.fr/ didier ACCU 2011 Thursday, April 14th 2/60 Table of contents 1 2 Symbolic Expressions 3 The of LISP 4 5 6 7 8 Dynamic 9 4/60 circularity

More information

CA Compiler Construction

CA Compiler Construction CA4003 - Compiler Construction Bottom Up Parsing David Sinclair Bottom Up Parsing LL(1) parsers have enjoyed a bit of a revival thanks to JavaCC. LL(k) parsers must predict which production rule to use

More information

Checking the Poisson assumption in the Poisson generalized linear model

Checking the Poisson assumption in the Poisson generalized linear model Checking the Poisson assumption in the Poisson generalized linear model The Poisson regression model is a generalized linear model (glm) satisfying the following assumptions: The responses y i are independent

More information

Listing up Combinations of Resistances

Listing up Combinations of Resistances Original Article 1 Listing up Combinations of Resistances ISOKAWA Yukinao* (Received 27 October, 2015) Abstract Circuits, nested connections of resistances in series and/or in parallel, are studied. We

More information

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88 Lisp Introduction Dr. Neil T. Dantam CSCI-498/598 RPM, Colorado School of Mines Spring 28 Dantam (Mines CSCI, RPM) Lisp Spring 28 / 88 Outline Lisp Common Lisp by Example Implementation Details Typing

More information

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ; 1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).

More information

Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1

Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1 Higher-Order Programming: Iterative computation (CTM Section 3.2) Closures, procedural abstraction, genericity, instantiation, embedding (CTM Section 3.6.1) Carlos Varela RPI September 15, 2015 Adapted

More information

Loop Convergence. CS 536: Science of Programming, Fall 2018

Loop Convergence. CS 536: Science of Programming, Fall 2018 Solved Loop Convergence CS 536: Science of Programming, Fall 2018 A. Why Diverging programs aren t useful, so it s useful to know how to show that loops terminate. B. Objectives At the end of this lecture

More information

CS Exam 1 Study Guide and Practice Exam

CS Exam 1 Study Guide and Practice Exam CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................

More information

Lisp Programming! Gunnar Gotshalks! LP-1

Lisp Programming! Gunnar Gotshalks! LP-1 Lisp Programming! LP-1 Boolean Functions! Return T for true and nil for false!» ( atom item )! > is item an atom, i.e. not a cons cell!» ( listp item )! > is item a list, i.e. a cons cell!» ( null item

More information

Organon: A Symbolic Constraint Framework & Solver Isaac Evans and Joseph Lynch

Organon: A Symbolic Constraint Framework & Solver Isaac Evans and Joseph Lynch Computer Science and Artificial Intelligence Laboratory Technical Report MIT-CSAIL-TR-2013-010 May 24, 2013 Organon: A Symbolic Constraint Framework & Solver Isaac Evans and Joseph Lynch massachusetts

More information

Associative Property. The word "associative" comes from "associate" or "group; the Associative Property is the rule that refers to grouping.

Associative Property. The word associative comes from associate or group; the Associative Property is the rule that refers to grouping. Associative Property The word "associative" comes from "associate" or "group; the Associative Property is the rule that refers to grouping. For addition, the rule is "a + (b + c) = (a + b) + c; in numbers,

More information

CS60007 Algorithm Design and Analysis 2018 Assignment 1

CS60007 Algorithm Design and Analysis 2018 Assignment 1 CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in

More information

Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1

Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1 Higher-Order Programming: Iterative computation (CTM Section 3.2) Closures, procedural abstraction, genericity, instantiation, embedding (CTM Section 3.6.1) Carlos Varela RPI September 15, 2017 Adapted

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms T. M. Murali February 19, 2013 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine

More information

Nondeterminism. September 7, Nondeterminism

Nondeterminism. September 7, Nondeterminism September 7, 204 Introduction is a useful concept that has a great impact on the theory of computation Introduction is a useful concept that has a great impact on the theory of computation So far in our

More information

HW #4. (mostly by) Salim Sarımurat. 1) Insert 6 2) Insert 8 3) Insert 30. 4) Insert S a.

HW #4. (mostly by) Salim Sarımurat. 1) Insert 6 2) Insert 8 3) Insert 30. 4) Insert S a. HW #4 (mostly by) Salim Sarımurat 04.12.2009 S. 1. 1. a. 1) Insert 6 2) Insert 8 3) Insert 30 4) Insert 40 2 5) Insert 50 6) Insert 61 7) Insert 70 1. b. 1) Insert 12 2) Insert 29 3) Insert 30 4) Insert

More information

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

More Turing Machines. CS154 Chris Pollett Mar 15, 2006. More Turing Machines CS154 Chris Pollett Mar 15, 2006. Outline Multitape Turing Machines Nondeterministic Turing Machines Enumerators Introduction There have been many different proposals for what it means

More information

University of New Mexico Department of Computer Science. Midterm Examination. CS 361 Data Structures and Algorithms Spring, 2003

University of New Mexico Department of Computer Science. Midterm Examination. CS 361 Data Structures and Algorithms Spring, 2003 University of New Mexico Department of Computer Science Midterm Examination CS 361 Data Structures and Algorithms Spring, 2003 Name: Email: Print your name and email, neatly in the space provided above;

More information

forty-two XLII Equivalent Computers? Lecture 40: Computing with Glue and Photons What is 42? cuarenta y dos Meaning of Numbers Meaning of Numbers

forty-two XLII Equivalent Computers? Lecture 40: Computing with Glue and Photons What is 42? cuarenta y dos Meaning of Numbers Meaning of Numbers ), #, R #,, - ), #, R #,, - Lecture 40: Computing with Glue and Photons Equivalent Computers? z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in

More information

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.

More information

Chapter 1: Constraints. Constraints. Constraints. Constraint Logic Programming. Peter Stuckey 1

Chapter 1: Constraints. Constraints. Constraints. Constraint Logic Programming. Peter Stuckey 1 Chapter 1: Constraints What are they, what do they do and what can I use them for. Constraints What are constraints? Modelling problems Constraint solving ree constraints Other constraint domains Properties

More information

Introduction to lambda calculus Part 6

Introduction to lambda calculus Part 6 Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho 2017-02-16 1 Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply

More information

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5. CSCC63 Worksheet Reducability For your reference, A T M is defined to be the language { M, w M accepts w}. 1 Reducability Theorem 5.1 HALT TM = { M, w M is a T M that halts on input w} is undecidable.

More information

Inferring Phylogenetic Trees. Distance Approaches. Representing distances. in rooted and unrooted trees. The distance approach to phylogenies

Inferring Phylogenetic Trees. Distance Approaches. Representing distances. in rooted and unrooted trees. The distance approach to phylogenies Inferring Phylogenetic Trees Distance Approaches Representing distances in rooted and unrooted trees The distance approach to phylogenies given: an n n matrix M where M ij is the distance between taxa

More information

Chapter 1: Constraints

Chapter 1: Constraints Chapter 1: Constraints What are they, what do they do and what can I use them for. 1 Constraints What are constraints? Modelling problems Constraint solving Tree constraints Other constraint domains Properties

More information

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12 CS 151 Red Black Trees & Structural Induction 1 Announcements Majors fair tonight 4:30-6:30pm in the Root Room in Carnegie. Come and find out about the CS major, or some other major. Winter Term in CS

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms T. M. Murali March 17, 2014 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine solutions

More information

Blocking Synchronization: Streams Vijay Saraswat (Dec 10, 2012)

Blocking Synchronization: Streams Vijay Saraswat (Dec 10, 2012) 1 Streams Blocking Synchronization: Streams Vijay Saraswat (Dec 10, 2012) Streams provide a very simple abstraction for determinate parallel computation. The intuition for streams is already present in

More information

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types

More information

Introduction to Python

Introduction to Python Introduction to Python Luis Pedro Coelho Institute for Molecular Medicine (Lisbon) Lisbon Machine Learning School II Luis Pedro Coelho (IMM) Introduction to Python Lisbon Machine Learning School II (1

More information

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm:

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: The maximum-subarray problem Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: Brute force algorithm: At best, θ(n 2 ) time complexity 129 Can we do divide

More information

Reference counting:

Reference counting: Invariant: Reference counting: Reference counting: 2 0 3 2 0 2 2 0 2 2 2 2 2 white gray r r r black do not ;; init-allocator : -> void? (define (init-allocator) (for ([i (in-range 0 (heap-size))])

More information

CS1800: Mathematical Induction. Professor Kevin Gold

CS1800: Mathematical Induction. Professor Kevin Gold CS1800: Mathematical Induction Professor Kevin Gold Induction: Used to Prove Patterns Just Keep Going For an algorithm, we may want to prove that it just keeps working, no matter how big the input size

More information

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine. The Class NP NP is the problems that can be solved in polynomial time by a nondeterministic machine. NP The time taken by nondeterministic TM is the length of the longest branch. The collection of all

More information

Denotational Semantics of Programs. : SimpleExp N.

Denotational Semantics of Programs. : SimpleExp N. Models of Computation, 2010 1 Denotational Semantics of Programs Denotational Semantics of SimpleExp We will define the denotational semantics of simple expressions using a function : SimpleExp N. Denotational

More information

L435/L555. Dept. of Linguistics, Indiana University Fall 2016

L435/L555. Dept. of Linguistics, Indiana University Fall 2016 in in L435/L555 Dept. of Linguistics, Indiana University Fall 2016 1 / 13 in we know how to output something on the screen: print( Hello world. ) input: input() returns the input from the keyboard

More information

MITOCW ocw f99-lec23_300k

MITOCW ocw f99-lec23_300k MITOCW ocw-18.06-f99-lec23_300k -- and lift-off on differential equations. So, this section is about how to solve a system of first order, first derivative, constant coefficient linear equations. And if

More information

Chapter 8: Recursion. March 10, 2008

Chapter 8: Recursion. March 10, 2008 Chapter 8: Recursion March 10, 2008 Outline 1 8.1 Recursively Defined Sequences 2 8.2 Solving Recurrence Relations by Iteration 3 8.4 General Recursive Definitions Recursively Defined Sequences As mentioned

More information

Fixed point iteration Numerical Analysis Math 465/565

Fixed point iteration Numerical Analysis Math 465/565 Fixed point iteration Numerical Analysis Math 465/565 1 Fixed Point Iteration Suppose we wanted to solve : f(x) = cos(x) x =0 or cos(x) =x We might consider a iteration of this type : x k+1 = cos(x k )

More information

1 Deterministic Turing Machines

1 Deterministic Turing Machines Time and Space Classes Exposition by William Gasarch 1 Deterministic Turing Machines Turing machines are a model of computation. It is believed that anything that can be computed can be computed by a Turing

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 24 Last time Relationship between models: deterministic/nondeterministic Class P Today Class NP Sofya Raskhodnikova Homework 9 due Homework 0 out 4/5/206 L24. I-clicker

More information

CSCI-141 Exam 1 Review September 19, 2015 Presented by the RIT Computer Science Community

CSCI-141 Exam 1 Review September 19, 2015 Presented by the RIT Computer Science Community CSCI-141 Exam 1 Review September 19, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Python basics (a) The programming language Python (circle the best answer): i. is primarily

More information

Quantum-inspired Huffman Coding

Quantum-inspired Huffman Coding Quantum-inspired Huffman Coding A. S. Tolba, M. Z. Rashad, and M. A. El-Dosuky Dept. of Computer Science, Faculty of Computers and Information Sciences, Mansoura University, Mansoura, Egypt. tolba_954@yahoo.com,

More information

CS 4349 Lecture August 30th, 2017

CS 4349 Lecture August 30th, 2017 CS 4349 Lecture August 30th, 2017 Main topics for #lecture include #recurrances. Prelude I will hold an extra office hour Friday, September 1st from 3:00pm to 4:00pm. Please fill out prerequisite forms

More information

Introduction to Python

Introduction to Python Introduction to Python Luis Pedro Coelho luis@luispedro.org @luispedrocoelho European Molecular Biology Laboratory Lisbon Machine Learning School 2015 Luis Pedro Coelho (@luispedrocoelho) Introduction

More information

All-Pairs Shortest Paths

All-Pairs Shortest Paths All-Pairs Shortest Paths Version of October 28, 2016 Version of October 28, 2016 All-Pairs Shortest Paths 1 / 26 Outline Another example of dynamic programming Will see two different dynamic programming

More information

Inverse Kinematics. Mike Bailey. Oregon State University. Inverse Kinematics

Inverse Kinematics. Mike Bailey. Oregon State University. Inverse Kinematics Inverse Kinematics Mike Bailey mjb@cs.oregonstate.edu inversekinematics.pptx Inverse Kinematics Forward Kinematics solves the problem if I know the link transformation parameters, where are the links?.

More information

Mathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review:

Mathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review: Mathematical Background Mathematical Background CSE 373 Data Structures Today, we will review: Logs and eponents Series Recursion Motivation for Algorithm Analysis 5 January 007 CSE 373 - Math Background

More information

Each of the relationships have their own patterns. Many of the patterns are similar and easy to recall.

Each of the relationships have their own patterns. Many of the patterns are similar and easy to recall. Proportional Reasoning Much of science and mathematics have a great deal to do with finding patterns. Many scientists spend a lot of time trying to determine how various variables are related mathematically

More information

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK Midlands Graduate School, University of Birmingham, April 2008 1 Operational Semantics Abstract Machines and Correctness Roy L. Crole University of Leicester, UK Midlands Graduate School, University of

More information

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation: Data structures Exercise 1 solution Question 1 Let s start by writing all the functions in big O notation: f 1 (n) = 2017 = O(1), f 2 (n) = 2 log 2 n = O(n 2 ), f 3 (n) = 2 n = O(2 n ), f 4 (n) = 1 = O

More information

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems Valentine Kabanets September 13, 2007 1 Complexity Classes Unless explicitly stated,

More information

Lecture 23: Introduction to Quantum Complexity Theory 1 REVIEW: CLASSICAL COMPLEXITY THEORY

Lecture 23: Introduction to Quantum Complexity Theory 1 REVIEW: CLASSICAL COMPLEXITY THEORY Quantum Computation (CMU 18-859BB, Fall 2015) Lecture 23: Introduction to Quantum Complexity Theory November 31, 2015 Lecturer: Ryan O Donnell Scribe: Will Griffin 1 REVIEW: CLASSICAL COMPLEXITY THEORY

More information

CS177 Spring Midterm 2. April 02, 8pm-9pm. There are 25 multiple choice questions. Each one is worth 4 points.

CS177 Spring Midterm 2. April 02, 8pm-9pm. There are 25 multiple choice questions. Each one is worth 4 points. CS177 Spring 2015 Midterm 2 April 02, 8pm-9pm There are 25 multiple choice questions. Each one is worth 4 points. Answer the questions on the bubble sheet given to you. Only the answers on the bubble sheet

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

/ \ ( )-----/\/\/\/ \ / In Lecture 3 we offered this as an example of a first order LTI system.

/ \ ( )-----/\/\/\/ \ / In Lecture 3 we offered this as an example of a first order LTI system. 18.03 Class 17, March 12, 2010 Linearity and time invariance [1] RLC [2] Superposition III [3] Time invariance [4] Review of solution methods [1] We've spent a lot of time with mx" + bx' + cx = q(t). There

More information

p 3 p 2 p 4 q 2 q 7 q 1 q 3 q 6 q 5

p 3 p 2 p 4 q 2 q 7 q 1 q 3 q 6 q 5 Discrete Fréchet distance Consider Professor Bille going for a walk with his personal dog. The professor follows a path of points p 1,..., p n and the dog follows a path of points q 1,..., q m. We assume

More information

Lecture 8: ES 102 Functions, Searching and Sorting

Lecture 8: ES 102 Functions, Searching and Sorting Lecture 8: ES 102 Functions, Searching and Sorting Introduction to Computing IIT Gandhinagar, India Oct 9th, 2013 Shivakumar,Bireswar (IIT Gandhinagar) Lecture 7 Oct 9th, 2013 1 / 16 Revising Functions

More information

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 CakeML Has: references, modules, datatypes, exceptions, a FFI,... Doesn t have:

More information

Learning Decision Trees

Learning Decision Trees Learning Decision Trees Machine Learning Fall 2018 Some slides from Tom Mitchell, Dan Roth and others 1 Key issues in machine learning Modeling How to formulate your problem as a machine learning problem?

More information

Turing Machines Part One

Turing Machines Part One Turing Machines Part One What problems can we solve with a computer? Regular Languages CFLs Languages recognizable by any feasible computing machine All Languages That same drawing, to scale. All Languages

More information

Error Detection and Correction: Small Applications of Exclusive-Or

Error Detection and Correction: Small Applications of Exclusive-Or Error Detection and Correction: Small Applications of Exclusive-Or Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin Exclusive-Or (XOR,

More information

Testing a Hash Function using Probability

Testing a Hash Function using Probability Testing a Hash Function using Probability Suppose you have a huge square turnip field with 1000 turnips growing in it. They are all perfectly evenly spaced in a regular pattern. Suppose also that the Germans

More information

Decision Trees Part 1. Rao Vemuri University of California, Davis

Decision Trees Part 1. Rao Vemuri University of California, Davis Decision Trees Part 1 Rao Vemuri University of California, Davis Overview What is a Decision Tree Sample Decision Trees How to Construct a Decision Tree Problems with Decision Trees Classification Vs Regression

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Formal proofs; Simple/strong induction; Mutual induction; Inductively defined sets; Recursively defined functions. Lecture 3 Ana Bove

More information

OBSERVING PROJECT PARTNER ELECTION

OBSERVING PROJECT PARTNER ELECTION Name(s) Section Day/Time OBSERVING PROJECT PARTNER ELECTION Fill in either Part 1 or Part 2. Part I. SOLO OBSERVER I will do the observing project by myself. I will not copy someone else's paper or show

More information

Functional Programming Laboratory 3

Functional Programming Laboratory 3 Functional Programming Laboratory 3 Define new functions, Recursion Isabela Drămnesc March 12, 2014 1 Concepts Bound and free variables Recursive functions Simple and double recursion 2 Questions from

More information

HW8. Due: November 1, 2018

HW8. Due: November 1, 2018 CSCI 1010 Theory of Computation HW8 Due: November 1, 2018 Attach a fully filled-in cover sheet to the front of your printed homework Your name should not appear anywhere; the cover sheet and each individual

More information

(defvar *ASSERTIONS* nil) ;;;top level interpreter loop (defun logic-shell ()

(defvar *ASSERTIONS* nil) ;;;top level interpreter loop (defun logic-shell () ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; LOGIC PROGRAMMING INTERPRETER ;;; ;;; from George Lugar and William Stubblefield ;;; Artificial Intelligence and the Design of Expert Systems

More information

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016 University of Toronto Department of Electrical and Computer Engineering Final Examination ECE 345 Algorithms and Data Structures Fall 2016 Print your first name, last name, UTORid, and student number neatly

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 10:

CMSC 132, Object-Oriented Programming II Summer Lecture 10: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 10: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 10.1 RECURSION

More information

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2 In-Class Soln 1 Let f(n) be an always positive function and let g(n) = f(n) log n. Show that f(n) = o(g(n)) CS 361, Lecture 4 Jared Saia University of New Mexico For any positive constant c, we want to

More information

Lab #2: Parallax & Introduction to Error Analysis

Lab #2: Parallax & Introduction to Error Analysis Lab #: Parallax & Introduction to Error Analysis February 6, 0 Due February 0, 0 by am Objectives: To understand and apply the techniques of parallax to measure the distances to terrestrial objects. To

More information

Lab Exercise #2: Solar Radiation & Temperature Part VI: An Even More Complex Computer Model

Lab Exercise #2: Solar Radiation & Temperature Part VI: An Even More Complex Computer Model METR 104: Our Dynamic Weather (w/lab) Lab Exercise #2: Solar Radiation & Temperature Part VI: An Even More Complex Computer Model Dr. Dave Dempsey Dept. of Geosciences Dr. Oswaldo Garcia, & Denise Balukas

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.2016.6.1 COMPUTER SCIENCE TRIPOS Part IB Thursday 2 June 2016 1.30 to 4.30 COMPUTER SCIENCE Paper 6 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.

More information

Dynamic Programming( Weighted Interval Scheduling)

Dynamic Programming( Weighted Interval Scheduling) Dynamic Programming( Weighted Interval Scheduling) 17 November, 2016 Dynamic Programming 1 Dynamic programming algorithms are used for optimization (for example, finding the shortest path between two points,

More information

λ λ λ λ ::= s t... ::= S ( ) S ::= x y... ::= λ :. λ. [] s t S ( t) t t t λ λ λ t.e λ E t E t S (λ t.e)[t ] T t E T x : T t ::= :,, E, E,... T, T,... X, X, X 1, X 2... X E :t X, x:t x:t T X X, t E :T X

More information

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent)

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent) TDDD08 Tutorial 1 Who? From? Victor Lagerkvist (& Wªodek Drabent) Theoretical Computer Science Laboratory, Linköpings Universitet, Sweden When? 6 september 2015 1 / 18 Preparations Before you start with

More information

Observation and Data Collection: Star Counting

Observation and Data Collection: Star Counting Observation and Data Collection: Star Counting Investigation: Do people everywhere see the same number of stars in the night sky? Why or why not? How many stars can you see on a clear night where you live?

More information

Stochastic Search: Part 2. Genetic Algorithms. Vincent A. Cicirello. Robotics Institute. Carnegie Mellon University

Stochastic Search: Part 2. Genetic Algorithms. Vincent A. Cicirello. Robotics Institute. Carnegie Mellon University Stochastic Search: Part 2 Genetic Algorithms Vincent A. Cicirello Robotics Institute Carnegie Mellon University 5000 Forbes Avenue Pittsburgh, PA 15213 cicirello@ri.cmu.edu 1 The Genetic Algorithm (GA)

More information

Ukkonen's suffix tree construction algorithm

Ukkonen's suffix tree construction algorithm Ukkonen's suffix tree construction algorithm aba$ $ab aba$ 2 2 1 1 $ab a ba $ 3 $ $ab a ba $ $ $ 1 2 4 1 String Algorithms; Nov 15 2007 Motivation Yet another suffix tree construction algorithm... Why?

More information

General Least Squares Fitting

General Least Squares Fitting Appendix B General Least Squares Fitting B.1 Introduction Previously you have done curve fitting in two dimensions. Now you will learn how to extend that to multiple dimensions. B.1.1 Linearizable Non-linear

More information

Cost of Substitution. (interp {with {x 1} {with {y 2} {+ 100 {+ 99 { {+ y x}}}}}} )

Cost of Substitution. (interp {with {x 1} {with {y 2} {+ 100 {+ 99 { {+ y x}}}}}} ) Cost of Substitution (interp {with {x 1} {with {y 2} {+ 100 {+ 99 {+ 98... {+ y x}}}}}} 1 Cost of Substitution (interp {with {x 1} {with {y 2} {+ 100 {+ 99 {+ 98... {+ y x}}}}}} (interp {with {y 2} {+

More information

Extensibility Patterns: Extension Access

Extensibility Patterns: Extension Access Design Patterns and Frameworks Dipl.-Medieninf. Christian Piechnick INF 2080 christian.piechnick@tu-dresden.de Exercise Sheet No. 5 Software Technology Group Institute for SMT Department of Computer Science

More information

Turing Machine Recap

Turing Machine Recap Turing Machine Recap DFA with (infinite) tape. One move: read, write, move, change state. High-level Points Church-Turing thesis: TMs are the most general computing devices. So far no counter example Every

More information