Slide 1. Slide 2 Midterm 1 You did great If you need a regrade, see the person that graded that question Solutions available on the portal soon.

Slides:



Advertisements
Similar presentations
Methods of Enumeration Counting tools can be very important in probability … particularly if you have a finite sample space with equally likely outcomes.
Advertisements

Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Recitation 8 Recursion and Linked Lists Ben Stoddard Tabitha Peck March 7, 2014.
Recursion (summary). Two Categories  Translation of recursive definition  Factorial: fact(1) = 1; fact(N) = N * fact(N-1)  Mystery: m(0) = 0; m(1)
CS3 Fall 2005 Lecture 11: Finish higher order functions Midterm Prep.
Slide 1 CS3: Lecture 8 Advanced recursion. Slide 2 Schedule Oct 10Advanced recursion Oct 17Number-spelling Miniproject Oct 24Higher order procedures Oct.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 14: Number Spelling Mini-project.
Past Midterm Review COMP171 Fall Midterm Review / Slide 2 Multiple Choices (1) (2)
Slide 1 CS3 Week 8: Recursion. Slide 2 Midterm 1 You did great If you need a re- grade, see the person that graded that question Solutions are available.
Slide 1. Slide 2 Administrivia Mid-semester survey this week (Thur/Fri) –you NEED to do this. Interviews should be starting in a few weeks. I apologize.
CS3 Fall 2005 Lecture 10: More on higher order functions.
6.001 SICP SICP – September Processes, Substitution, Recusion, and Iteration Trevor Darrell 32-D web page:
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project.
CS3: Introduction to Symbolic Programming Spring 2006Nate Titterton Lecture 4: "Difference Between Dates" and data abstraction.
Slide 1 Midterm 1 Midterm 1: Feb 28 th (next week). –In the lecture slot, plus 20 minutes (4:10-5:30 pm, 120 Latimer) –Everything we’ve covered, including.
CIS 630 Slides for March Schedule We missed two classes. I will try to make up in April Spring break– Week of March 8 Your presentations I would.
Data Abstraction… The truth comes out…. What we’re doing today… Abstraction ADT: Dotted Pair ADT: List Box and Pointer List Recursion Deep List Recursion.
CS 330 Programming Languages 11 / 20 / 2007 Instructor: Michael Eckmann.
Recursion Road Map Introduction to Recursion Recursion Example #1: World’s Simplest Recursion Program Visualizing Recursion –Using Stacks Recursion Example.
Administrivia Make sure you have completed the Mid Semester Survey –Scheduled the week before Spring Break –this will be worth some points Reading is.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 11: Accumulating Recursion.
Feb 28More complicated recursions March 7Tree recursion, etc. Number-spelling Miniproject (#2) March 14Higher order procedures March 21Spring Break March.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
CS3: Introduction to Symbolic Programming Spring 2006Nate Titterton Lecture 2: Introduction, and Conditionals.
מבוא מורחב - שיעור 81 Lecture 8 Lists and list operations (continue).
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 8: Recursion.
Midterm Logistics Where? 4 Leconte ( When? Monday, 4:10 to 5:40 What to do? –“Review problems”
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 9: Recursion Rocks!
CS 3 Final Review Gilbert Chou, Jenny Franco and Colleen Lewis December 14, pm GPB.
Midterm Logistics Where? 2050 VLSB When? Monday, 4:10 to 5:40 What to do? –“Review problems” from Thursday/Friday in UCWise. –Two practice exams and solutions.
Slide 1 CS3 Fall 2005 Lecture 9: Higher Order Functions.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 15: Procedures as Arguments.
EXAMPLE 4 Use Pascal’s triangle School Clubs The 6 members of a Model UN club must choose 2 representatives to attend a state convention. Use Pascal’s.
Programming Principles II Lecture Notes 5 Recursion Andreas Savva.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 9- 1.
Copyright © 2011 Pearson, Inc. 9.2 The Binomial Theorem.
CS61A Lecture Colleen Lewis. Clicker Query What else are you doing this summer? A)Taking another class B)Working C)Taking another class and.
Recursion: Linear and Tree Recursive Processes and Iteration CMSC Introduction to Computer Programming October 7, 2002.
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
1 CSC 321: Data Structures Fall 2013 Counting and problem solving  mappings, bijection rule  sequences, product rule, sum rule  generalized product.
CS535 Programming Languages Chapter - 10 Functional Programming With Lists.
Dynamic Programming. Many problem can be solved by D&C – (in fact, D&C is a very powerful approach if you generalize it since MOST problems can be solved.
Review I. Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11.
4th Grade Common Core Math Practice and Solutions for 4th Grade Common Core Math Standard 4.NF.7 Multiple Choice Set #1 without Answers Multiple Choice.
Computer Eng. Software Lab II , Semester 2, Who I am: Andrew Davison CoE, WiG Lab Office Functional Programming.
CS3: Introduction to Symbolic Programming Spring 2006Nate Titterton Lecture 2: Introduction, and Conditionals.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
nest join song barks asks dog Yes
CS314 – Section 5 Recitation 10
The Pigeonhole Principle
CSC 321: Data Structures Fall 2015 Counting and problem solving
Midterm Review.
Prime and Composite.
CMSC201 Computer Science I for Majors Lecture 18 – Recursion
A quick and efficient way to expand binomials
Lists in Lisp and Scheme
COP4020 Programming Languages
Problem Solving: Brute Force Approaches
Patterns, Patterns, and more Patterns!
Unit-2 Divide and Conquer
Multiplying and Dividing Integers

slides created by Marty Stepp and Alyssa Harding
Year 2 Spring Term Week 8 Lesson 4
List and list operations (continue).
Pages NOTE: On a single line, any point that is a solution will fall on the line. Any point that is NOT a solution, will be a point that is NOT on.
Year 2 Spring Term Week 8 Lesson 4
Presentation transcript:

Slide 1

Slide 2 Midterm 1 You did great If you need a regrade, see the person that graded that question Solutions available on the portal soon.

Slide 3 Schedule Feb 28Midterm #1 March 7Tree recursion, etc. Number-spelling Miniproject March 14Higher order procedures March 21Spring Break March 28More HOF Lists! (instead of sentences and words) April 4Recursion (advanced) April 11Midterm #2

Slide 4 Number Spelling Read Simply Scheme, page 233, which has hints Another hint (principle): don't force "everything" into the recursion.

Slide 5 Problem: find all the even numbers in sentence of numbers (define (find-evens sent) (cond ( ;base case ) ( ;rec case 1: odd ) ( ;rec case 2: even ) )) (define (find-evens sent) (cond ((empty? sent) ;base case '() ) ((odd? (first sent)) ;rec case 1 (find-evens (bf sent)) ) (else ;rec case 2: even (se (first sent) (find-evens (bf sent))) ) ))

Slide 6 > (find-evens '( ))  (se 2 (se 4 (se 6 ())  (2 4 6) (se 2 (se 4 (se 6 () sent = ( ) sent = ( ) sent = ( ) sent = ( 5 6 ) sent = ( 6 ) sent = ( )

Slide 7 Why is recursion hard? ONE function: –replicates itself, –knows how to stop, –knows how to combine the “replications” There are many ways to think about recursion: you absolutely do not need to understand all of them. –Knowing recursion WILL help with all sorts of ways while programming, even if you don’t often use it.

Slide 8 Recursive patterns Most recursive functions that operate on a sentence fall into: –Mapping: square-all –Counting: count-vowels, count-evens –Finding: member, first-even –Filtering: keep-evens –Testing: all-even? –Combining: sum-evens

Slide 9 What recursions aren’t covered by these patterns? Weird ones like reverse, or downup Ones that don’t traverse a single sentence –E.g., mad-libs takes a sentence of replacement words [e.g., ‘(fat Henry three) ] and a sentence to mutate [e.g., ‘(I saw a * horse named * with * legs) ] Tree recursion: multiple recursive calls in a single recursive step

Slide 10 Advanced recursion columns (C) r o w s (R) Pascal’s Triangle How many ways can you choose C things from R choices? Coefficients of the (x+y)^R: look in row R etc.

Slide 11 pair-all Write pair-all, which takes a sentence of prefixes and a sentence of suffixes and returns a sentence pairing all prefixes to all suffixes. –(pair-all ‘(a b c) ‘(1 2 3))  (a1 b1 c1 a2 b2 c2 a3 b3 c3) –(pair-all ‘(spr s k) ‘(ite at ing ong))  (sprite sprat spring sprong site sat sing song kite kat king kong)