Lecture 14. Recursion

Size: px
Start display at page:

Download "Lecture 14. Recursion"

Transcription

1 Leture 14 Reursion

2 Announements for Today Prelim 1 Tonight at 5:15 OR 7:30 A D (5:15, Uris G01) E-K (5:15, Statler) L P (7:30, Uris G01) Q-Z (7:30, Statler) Graded y noon on Sun Sores will e in CMS In time for drop date Other Announements Reading: Assignment 3 now graded Mean 93.4, Median 98 Time: 7 hrs, StdDev: 3.5 hrs But only 535 responses Assignment 4 posted Friday Parts 1-3: Can do already Part 4: material from today Due two weeks from today 10/11/18 Reursion 2

3 Reursion Reursive Definition: A definition that is defined in terms of itself Reursive Funtion: A funtion that alls itself (diretly or indiretly) PIP stands for PIP Installs Pakages 10/11/18 Reursion 3

4 A Mathematial Example: Fatorial Non-reursive definition: n! = n n = n (n-1 2 1) Reursive definition: n! = n (n-1)! for n 0 0! = 1 Reursive ase Base ase What happens if there is no ase ase? 10/11/18 Reursion 4

5 Fatorial as a Reursive Funtion def fatorial(n): """Returns: fatorial of n. Pre: n 0 an int""" if n == 0: return 1 n! = n (n-1)! 0! = 1 Base ase(s) return n*fatorial(n-1) Reursive ase What happens if there is no ase ase? 10/11/18 Reursion 5

6 Example: Fionnai Sequene Sequene of numers: 1, 1, 2, 3, 5, 8, 13,... a 0 a 1 a 2 a 3 a 4 a 5 a 6 Get the next numer y adding previous two What is a 8? A: a 8 = 21 B: a 8 = 29 C: a 8 = 34 D: None of these. 10/11/18 Reursion 6

7 Example: Fionnai Sequene Sequene of numers: 1, 1, 2, 3, 5, 8, 13,... a 0 a 1 a 2 a 3 a 4 a 5 a 6 Get the next numer y adding previous two What is a 8? A: a 8 = 21 B: a 8 = 29 C: a 8 = 34 orret D: None of these. 10/11/18 Reursion 7

8 Example: Fionnai Sequene Sequene of numers: 1, 1, 2, 3, 5, 8, 13,... a 0 a 1 a 2 a 3 a 4 a 5 a 6 Get the next numer y adding previous two What is a 8? Reursive definition: a n = a n-1 + a n-2 Reursive Case a 0 = 1 Base Case a 1 = 1 (another) Base Case Why did we need two ase ases this time? 10/11/18 Reursion 8

9 Fionai as a Reursive Funtion def fionai(n): """Returns: Fionai no. a n Preondition: n 0 an int""" if n <= 1: return 1 Base ase(s) return (fionai(n-1)+ fionai(n-2)) Reursive ase Note differene with ase ase onditional. 10/11/18 Reursion 9

10 Fionai as a Reursive Funtion def fionai(n): """Returns: Fionai no. a n Preondition: n 0 an int""" if n <= 1: return 1 Funtion that alls itself Eah all is new frame Frames require memory alls = memory fionai 3 return (fionai(n-1)+ fionai(n-2)) n 5 fionai 1 fionai 1 n 4 n 3 10/11/18 Reursion 10

11 Fionai: # of Frames vs. # of Calls Fionai is very ineffiient. fi(n) has a stak that is always n But fi(n) makes a lot of redundant alls fi(5) fi(4) fi(3) fi(3) fi(2) fi(2) fi(1) fi(2) fi(1) fi(1) fi(0) fi(1) fi(0) 10/11/18 fi(1) fi(0) Reursion 11

12 Fionai: # of Frames vs. # of Calls Fionai is very ineffiient. fi(n) has a stak that is always n But fi(n) makes a lot of redundant alls Path to end = the all stak fi(4) fi(5) fi(3) fi(3) fi(2) fi(2) fi(1) fi(2) fi(1) fi(1) fi(0) fi(1) fi(0) 10/11/18 fi(1) fi(0) Reursion 12

13 Reursion vs Iteration Reursion is provaly equivalent to iteration Iteration inludes for-loop and while-loop (later) Anything an do in one, an do in the other But some things are easier with reursion And some things are easier with iteration Will not teah you when to hoose reursion This is a topi for more advaned lasses We just want you to understand the tehnique 10/11/18 Reursion 13

14 Reursion is est for Divide and Conquer Goal: Solve prolem P on a piee of data data 10/11/18 Reursion 14

15 Reursion is est for Divide and Conquer Goal: Solve prolem P on a piee of data data Idea: Split data into two parts and solve prolem data 1 data 2 Solve Prolem P Solve Prolem P 10/11/18 Reursion 15

16 Reursion is est for Divide and Conquer Goal: Solve prolem P on a piee of data data Idea: Split data into two parts and solve prolem data 1 data 2 Solve Prolem P Solve Prolem P Comine Answer! 10/11/18 Reursion 16

17 Divide and Conquer Example Count the numer of 'e's in a string: p e n n e Two 'e's p e n n e One 'e' One 'e' 10/11/18 Reursion 17

18 Divide and Conquer Example Count the numer of 'e's in a string: p e n n e Two 'e's p e n n e Zero 'e's Two 'e's 10/11/18 Reursion 18

19 Divide and Conquer Example Count the numer of 'e's in a string: p e n n e Two 'e's Will talk aout how to reak-up later p e n n e Zero 'e's Two 'e's 10/11/18 Reursion 19

20 Three Steps for Divide and Conquer 1. Deide what to do on small data Some data annot e roken up Have to ompute this answer diretly 2. Deide how to reak up your data Both halves should e smaller than whole Often no wrong way to do this (next leture) 3. Deide how to omine your answers Assume the smaller answers are orret Comining them should give igger answer 10/11/18 Reursion 20

21 Divide and Conquer Example def num_es(s): """Returns: # of 'e's in s""" # 1. Handle small data if s == '': return 0 elif len(s) == 1: return 1 if s[0] == 'e' else 0 # 2. Break into two parts left = num_es(s[0]) right = num_es(s[1:]) # 3. Comine the result return left+right s[0] Short-ut for if s[0] == 'e : return 1 else: return 0 s[1:] p e n n e 10/11/18 Reursion 21

22 Divide and Conquer Example def num_es(s): """Returns: # of 'e's in s""" # 1. Handle small data if s == '': return 0 elif len(s) == 1: return 1 if s[0] == 'e' else 0 # 2. Break into two parts left = num_es(s[0]) right = num_es(s[1:]) # 3. Comine the result return left+right s[0] Short-ut for if s[0] == 'e : return 1 else: return 0 s[1:] p e n n e 10/11/18 Reursion 22

23 Divide and Conquer Example def num_es(s): """Returns: # of 'e's in s""" # 1. Handle small data if s == '': return 0 elif len(s) == 1: return 1 if s[0] == 'e' else 0 # 2. Break into two parts left = num_es(s[0]) right = num_es(s[1:]) # 3. Comine the result return left+right s[0] Short-ut for if s[0] == 'e : return 1 else: return 0 s[1:] p e n n e 10/11/18 Reursion 23

24 Divide and Conquer Example def num_es(s): """Returns: # of 'e's in s""" # 1. Handle small data if s == '': return 0 elif len(s) == 1: return 1 if s[0] == 'e' else 0 # 2. Break into two parts left = num_es(s[0]) right = num_es(s[1:]) # 3. Comine the result return left+right s[0] Short-ut for if s[0] == 'e : return 1 else: return 0 s[1:] p e n n e 10/11/18 Reursion 24

25 Divide and Conquer Example def num_es(s): """Returns: # of 'e's in s""" # 1. Handle small data if s == '': return 0 elif len(s) == 1: return 1 if s[0] == 'e' else 0 Base Case # 2. Break into two parts left = num_es(s[0]) right = num_es(s[1:]) # 3. Comine the result return left+right Reursive Case 10/11/18 Reursion 25

26 Exerise: Remove Blanks from a String def (s): """Returns: s ut with its lanks removed""" 1. Deide what to do on small data If it is the empty string, nothing to do if s == '': return s If it is a single harater, delete it if a lank if s == ' ': # There is a spae here return '' # Empty string else: return s 10/11/18 Reursion 26

27 Exerise: Remove Blanks from a String def (s): """Returns: s ut with its lanks removed""" 2. Deide how to reak it up left = (s[0]) # A string with no lanks right = (s[1:]) # A string with no lanks 3. Deide how to omine the answer return left+right # String onatenation 10/11/18 Reursion 27

28 Putting it All Together def (s): """Returns: s w/o lanks""" if s == '': return s elif len(s) == 1: return '' if s[0] == ' ' else s Handle small data left = (s[0]) right = (s[1:]) Break up the data return left+right Comine answers 10/11/18 Reursion 28

29 Putting it All Together def (s): """Returns: s w/o lanks""" if s == '': return s elif len(s) == 1: return '' if s[0] == ' ' else s Base Case left = (s[0]) right = (s[1:]) return left+right Reursive Case 10/11/18 Reursion 29

30 Minor Optimization def (s): """Returns: s w/o lanks""" if s == '': return s elif len(s) == 1: return '' if s[0] == ' ' else s left = (s[0]) right = (s[1:]) Needed seond ase ase to handle s[0] return left+right 10/11/18 Reursion 30

31 Minor Optimization def (s): """Returns: s w/o lanks""" if s == '': return s left = s[0] if s[0] == ' ': left = '' right = (s[1:]) Eliminate the seond ase y omining return left+right Less reursive alls 10/11/18 Reursion 31

32 Following the Reursion a 10/11/18 Reursion 32

33 Following the Reursion a a 10/11/18 Reursion 33

34 Following the Reursion a a a 10/11/18 Reursion 34

35 Following the Reursion a a a 10/11/18 Reursion 35

36 Following the Reursion a a a 10/11/18 Reursion 36

37 Following the Reursion a a a 10/11/18 Reursion 37

38 Following the Reursion a a a 10/11/18 Reursion 38

39 Following the Reursion a a a 10/11/18 Reursion 39

40 Following the Reursion a a a 10/11/18 Reursion 40

41 Following the Reursion a a a 10/11/18 Reursion 41

42 Following the Reursion a a a 10/11/18 Reursion 42

43 Following the Reursion a a a a 10/11/18 Reursion 43

44 Following the Reursion a a a a a 10/11/18 Reursion 44

45 Following the Reursion a a a a a a 10/11/18 Reursion 45

46 Final Modifiation def (s): """Returns: s w/o lanks""" if s == '': return s left = s[0] if s[0] == ' ': left = '' right = (s[1:]) return left+right Real work done here 10/11/18 Reursion 46

47 Final Modifiation def (s): """Returns: s w/o lanks""" if s == '': return s Real work done here left = s if s[0] in string.whitespae left = '' right = (s[1:]) Module string has speial onstants to simplify detetion of whitespae and other haraters. return left+right 10/11/18 Reursion 47

48 Next Time: Breaking Up Reursion 10/11/18 Reursion 48

Recursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3

Recursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3 Reursion eamples: Problem 2 (More) Reursion and s Reursive funtion to reverse a string publi String revstring(string str) { if(str.equals( )) return str; return revstring(str.substring(1, str.length()))

More information

1 Disjoint-set data structure.

1 Disjoint-set data structure. CS 124 Setion #4 Union-Fin, Greey Algorithms 2/20/17 1 Disjoint-set ata struture. 1.1 Operations Disjoint-set ata struture enale us to effiiently perform operations suh as plaing elements into sets, querying

More information

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Test I Solutions

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Test I Solutions Department of Eletrial Engineering and Computer iene MAACHUETT INTITUTE OF TECHNOLOGY 6.035 Fall 2016 Test I olutions 1 I Regular Expressions and Finite-tate Automata For Questions 1, 2, and 3, let the

More information

Dynamic Algorithms Multiple Choice Test

Dynamic Algorithms Multiple Choice Test 3226 Dynami Algorithms Multiple Choie Test Sample test: only 8 questions 32 minutes (Real test has 30 questions 120 minutes) Årskort Name Eah of the following 8 questions has 4 possible answers of whih

More information

Compilation Lecture 11a. Register Allocation Noam Rinetzky. Text book: Modern compiler implementation in C Andrew A.

Compilation Lecture 11a. Register Allocation Noam Rinetzky. Text book: Modern compiler implementation in C Andrew A. Compilation 0368-3133 Leture 11a Text book: Modern ompiler implementation in C Andrew A. Appel Register Alloation Noam Rinetzky 1 Registers Dediated memory loations that an be aessed quikly, an have omputations

More information

CS Prelim 2 Review Fall 2018

CS Prelim 2 Review Fall 2018 CS 1110 Prelim 2 Review Fall 2018 Exam Info Prelim 1: Thursday, November 8th Last name L P at 5:15 6:45 in Uris G01 Last name Q Z at 5:15 6:45 in Statler Aud. Last name A D at 7:30 9:00 in Uris G01 Last

More information

Outline: Software Design

Outline: Software Design Outline: Software Design. Goals History of software design ideas Design priniples Design methods Life belt or leg iron? (Budgen) Copyright Nany Leveson, Sept. 1999 A Little History... At first, struggling

More information

Algorithms for External Memory Lecture 6 Graph Algorithms - Weighted List Ranking

Algorithms for External Memory Lecture 6 Graph Algorithms - Weighted List Ranking Algorithms for External Memory Leture 6 Graph Algorithms - Weighted List Ranking Leturer: Nodari Sithinava Sribe: Andi Hellmund, Simon Ohsenreither 1 Introdution & Motivation After talking about I/O-effiient

More information

Data Structures in Java

Data Structures in Java Data Strutures in Java Leture 8: Trees and Tree Traversals. 10/5/2015 Daniel Bauer 1 Trees in Computer Siene A lot of data omes in a hierarhial/nested struture. Mathematial expressions. Program struture.

More information

COMP 181. Prelude. Intermediate representations. Today. Types of IRs. High-level IR. Intermediate representations and code generation

COMP 181. Prelude. Intermediate representations. Today. Types of IRs. High-level IR. Intermediate representations and code generation Prelude COMP 181 Intermediate representations and ode generation November, 009 What is this devie? Large Hadron Collider What is a hadron? Subatomi partile made up of quarks bound by the strong fore What

More information

Lecture 15. More Recursion

Lecture 15. More Recursion Lecture 15 More Recursion Announcements for This Lecture Prelim 1 Prelim 1 back today! Access in Gradescope Solution posted in CMS Mean: 71, Median: 74 Testing was horrible What are letter grades? A: 80

More information

Register Allocation III. Interference Graph Allocators. Computing the Interference Graph (in MiniJava compiler)

Register Allocation III. Interference Graph Allocators. Computing the Interference Graph (in MiniJava compiler) Register Alloation III Announements Reommen have interferene graph onstrution working by Monay Last leture Register alloation aross funtion alls Toay Register alloation options Interferene Graph Alloators

More information

Back To LinkedLists 1. 3 public Node left; 4 public Node right; 6 public Node(int data, Node left, Node right) {

Back To LinkedLists 1. 3 public Node left; 4 public Node right; 6 public Node(int data, Node left, Node right) { Adam Blank Leture Autumn 0 CSE 3X Aelerated Computer Programming I/II CSE 3X: Aelerated Computer Programming I/II Binary Trees 0 00 00 00 00 0 000 00 00 0 00 0 000 000 000 0 0 00 0000 00 000 00 00 0 000

More information

Race Conditions & Synchronization

Race Conditions & Synchronization Gries office hours 2 A numer of students have asked for time to talk over how to study for the prelim. Gries will hold office hours at the times elow for this purpose. Also, read asiclearningmethods.pdf

More information

Dynamic Programming. Lecture #8 of Algorithms, Data structures and Complexity. Joost-Pieter Katoen Formal Methods and Tools Group

Dynamic Programming. Lecture #8 of Algorithms, Data structures and Complexity. Joost-Pieter Katoen Formal Methods and Tools Group Dynami Programming Leture #8 of Algorithms, Data strutures and Complexity Joost-Pieter Katoen Formal Methods and Tools Group E-mail: katoen@s.utwente.nl Otober 29, 2002 JPK #8: Dynami Programming ADC (214020)

More information

Gray Codes for Reflectable Languages

Gray Codes for Reflectable Languages Gray Codes for Refletable Languages Yue Li Joe Sawada Marh 8, 2008 Abstrat We lassify a type of language alled a refletable language. We then develop a generi algorithm that an be used to list all strings

More information

Definitions Homework. Quine McCluskey Optimal solutions are possible for some large functions Espresso heuristic. Definitions Homework

Definitions Homework. Quine McCluskey Optimal solutions are possible for some large functions Espresso heuristic. Definitions Homework EECS 33 There be Dragons here http://ziyang.ees.northwestern.edu/ees33/ Teaher: Offie: Email: Phone: L477 Teh dikrp@northwestern.edu 847 467 2298 Today s material might at first appear diffiult Perhaps

More information

Layout Compliance for Triple Patterning Lithography: An Iterative Approach

Layout Compliance for Triple Patterning Lithography: An Iterative Approach Layout Compliane for Triple Patterning Lithography: An Iterative Approah Bei Yu, Gilda Garreton, David Z. Pan ECE Dept. University of Texas at Austin, Austin, TX, USA Orale Las, Orale Corporation, Redwood

More information

Lecture 22. While Loops

Lecture 22. While Loops Lecture 22 While Loops Announcements for This Lecture Assignments Prelim 2 A5 is now graded Will be returned in lab Mean: 52 Median: 53 Std Dev: 5.5 Passing Grade: 30 A6 due next Tuesday Dataset should

More information

Parametric Abstract Domains for Shape Analysis

Parametric Abstract Domains for Shape Analysis Parametri Abstrat Domains for Shape Analysis Xavier RIVAL (INRIA & Éole Normale Supérieure) Joint work with Bor-Yuh Evan CHANG (University of Maryland U University of Colorado) and George NECULA (University

More information

PASCAL 64. "The" Pascal Compiler for the Commodore 64. A Data Becker Product. >AbacusiII Software P.O. BOX 7211 GRAND RAPIDS, MICK 49510

PASCAL 64. The Pascal Compiler for the Commodore 64. A Data Becker Product. >AbacusiII Software P.O. BOX 7211 GRAND RAPIDS, MICK 49510 PASCAL 64 "The" Pasal Compiler for the Commodore 64 A Data Beker Produt >AbausiII Software P.O. BOX 7211 GRAND RAPIDS, MICK 49510 7010 COPYRIGHT NOTICE ABACUS Software makes this pakage available for use

More information

ECE 242 Fall Tilman Wolf 1. Character- by- character processing Special operators

ECE 242 Fall Tilman Wolf 1. Character- by- character processing Special operators State Mahines University of Massahuse4s Amherst ECE 242 Data Strutures an Algorithms Leture 24 ECE 242 Fall 2013 2013 Tilman Wolf 1 Regular expressions Metho to esrie pa4erns of text Charater- y- harater

More information

Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Python review. 1 Python basics. References. CS 234 Naomi Nishimura Python review CS 234 Naomi Nishimura The sections below indicate Python material, the degree to which it will be used in the course, and various resources you can use to review the material. You are not

More information

Register Allocation III. Interference Graph Allocators. Coalescing. Granularity of Allocation (Renumber step in Briggs) Chaitin

Register Allocation III. Interference Graph Allocators. Coalescing. Granularity of Allocation (Renumber step in Briggs) Chaitin Register Alloation III Last time Register alloation aross funtion alls Toay Register alloation options Interferene Graph Alloators Chaitin Briggs CS553 Leture Register Alloation III 1 CS553 Leture Register

More information

Drawing lines. Naïve line drawing algorithm. drawpixel(x, round(y)); double dy = y1 - y0; double dx = x1 - x0; double m = dy / dx; double y = y0;

Drawing lines. Naïve line drawing algorithm. drawpixel(x, round(y)); double dy = y1 - y0; double dx = x1 - x0; double m = dy / dx; double y = y0; Naïve line drawing algorithm // Connet to grid points(x0,y0) and // (x1,y1) by a line. void drawline(int x0, int y0, int x1, int y1) { int x; double dy = y1 - y0; double dx = x1 - x0; double m = dy / dx;

More information

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15 1 LECTURE 1: INTRO Introduction to Scientific Python, CME 193 Jan. 9, 2014 web.stanford.edu/~ermartin/teaching/cme193-winter15 Eileen Martin Some slides are from Sven Schmit s Fall 14 slides 2 Course Details

More information

CS Prelim 2 Review Fall 2017

CS Prelim 2 Review Fall 2017 CS 1110 Prelim 2 Review Fall 2017 Exam Info Prelim 2: 7:30 9:00PM, Thursday, Nov. 9th Last name A J in Uris G01 Last name K Z in Statler Auditorium SDS Students will get an e-mail To help you study: Study

More information

Study of RNA Secondary Structure Prediction Algorithms

Study of RNA Secondary Structure Prediction Algorithms San Jose State University SJSU SholarWorks Master's Projets Master's Theses and Graduate Researh 2006 Study of RNA Seondary Struture Predition Algorithms Lisa Yu San Jose State University Follow this and

More information

Lecture 12. Lists (& Sequences)

Lecture 12. Lists (& Sequences) Lecture Lists (& Sequences) Announcements for Today Reading Read 0.0-0., 0.4-0.6 Read all of Chapter 8 for Tue Prelim, Oct th 7:30-9:30 Material up to October 3rd Study guide net week Conflict with Prelim

More information

CS 151. Recursion (Review!) Wednesday, September 19, 12

CS 151. Recursion (Review!) Wednesday, September 19, 12 CS 151 Recursion (Review!) 1 Announcements no class on Friday, and no office hours either (Alexa out of town) unfortunately, Alexa will also just be incommunicado, even via email, from Wednesday night

More information

CS Prelim 1 Review Fall 2018

CS Prelim 1 Review Fall 2018 CS 1110 Prelim 1 Review Fall 2018 Exam Info Prelim 1: Thursday, October 12th Last name A D at 5:15 6:45 in Uris G01 Last name E K at 5:15 6:45 in Statler Aud. Last name L P at 7:30 9:00 in Uris G01 Last

More information

Chapter 2: Introduction to Maple V

Chapter 2: Introduction to Maple V Chapter 2: Introdution to Maple V 2-1 Working with Maple Worksheets Try It! (p. 15) Start a Maple session with an empty worksheet. The name of the worksheet should be Untitled (1). Use one of the standard

More information

Mining Edge-Weighted Call Graphs to Localise Software Bugs

Mining Edge-Weighted Call Graphs to Localise Software Bugs Mining Edge-Weighted Call Graphs to Loalise Software Bugs Frank Eihinger, Klemens Böhm, and Matthias Huer Institute for Program Strutures and Data Organisation (IPD), Universität Karlsruhe (TH), Germany

More information

Computational Biology 6.095/6.895 Database Search Lecture 5 Prof. Piotr Indyk

Computational Biology 6.095/6.895 Database Search Lecture 5 Prof. Piotr Indyk Computational Biology 6.095/6.895 Database Searh Leture 5 Prof. Piotr Indyk Previous letures Leture -3: Global alignment in O(mn) Dynami programming Leture -2: Loal alignment, variants, in O(mn) Leture

More information

CS 111X - Spring Final Exam - KEY

CS 111X - Spring Final Exam - KEY CS 111X - Spring 2016 - Final Exam 1/10 Computing ID: CS 111X - Spring 2016 - Final Exam - KEY Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance on

More information

CS21: INTRODUCTION TO COMPUTER SCIENCE. Prof. Mathieson Fall 2018 Swarthmore College

CS21: INTRODUCTION TO COMPUTER SCIENCE. Prof. Mathieson Fall 2018 Swarthmore College CS21: INTRODUCTION TO COMPUTER SCIENCE Prof. Mathieson Fall 2018 Swarthmore College Outline Oct 24: Sit somewhere new! Recap reading files String and List methods TDD: Top Down Design word_guesser.py Notes

More information

Machine Vision. Laboratory Exercise Name: Student ID: S

Machine Vision. Laboratory Exercise Name: Student ID: S Mahine Vision 521466S Laoratory Eerise 2011 Name: Student D: General nformation To pass these laoratory works, you should answer all questions (Q.y) with an understandale handwriting either in English

More information

Finding the Equation of a Straight Line

Finding the Equation of a Straight Line Finding the Equation of a Straight Line You should have, before now, ome aross the equation of a straight line, perhaps at shool. Engineers use this equation to help determine how one quantity is related

More information

Introductory Programming, IMM, DTU Systematic Software Test. Software test (afprøvning) Motivation. Structural test and functional test

Introductory Programming, IMM, DTU Systematic Software Test. Software test (afprøvning) Motivation. Structural test and functional test Introdutory Programming, IMM, DTU Systemati Software Test Peter Sestoft a Programs often ontain unintended errors how do you find them? Strutural test Funtional test Notes: Systemati Software Test, http://www.dina.kvl.dk/

More information

Divide-and-conquer algorithms 1

Divide-and-conquer algorithms 1 * 1 Multipliation Divide-and-onquer algorithms 1 The mathematiian Gauss one notied that although the produt of two omplex numbers seems to! involve four real-number multipliations it an in fat be done

More information

Announcements SORTING. Prelim 1. Announcements. A3 Comments 9/26/17. This semester s event is on Saturday, November 4 Apply to be a teacher!

Announcements SORTING. Prelim 1. Announcements. A3 Comments 9/26/17. This semester s event is on Saturday, November 4 Apply to be a teacher! Announcements 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Lecture 11 CS2110 Fall 2017 is a program wit a teac anyting, learn

More information

Lists, loops and decisions

Lists, loops and decisions Caltech/LEAD Summer 2012 Computer Science Lecture 4: July 11, 2012 Lists, loops and decisions Lists Today Looping with the for statement Making decisions with the if statement Lists A list is a sequence

More information

UCSB Math TI-85 Tutorials: Basics

UCSB Math TI-85 Tutorials: Basics 3 UCSB Math TI-85 Tutorials: Basis If your alulator sreen doesn t show anything, try adjusting the ontrast aording to the instrutions on page 3, or page I-3, of the alulator manual You should read the

More information

CS 188: Artificial Intelligence Fall Search Gone Wrong?

CS 188: Artificial Intelligence Fall Search Gone Wrong? CS 188: Artificial Intelligence Fall 2009 Lecture 3: A* Search 9/3/2009 Pieter Aeel UC Berkeley Many slides from Dan Klein Search Gone Wrong? 1 Announcements Assignments: Project 0 (Python tutorial): due

More information

Boosted Random Forest

Boosted Random Forest Boosted Random Forest Yohei Mishina, Masamitsu suhiya and Hironobu Fujiyoshi Department of Computer Siene, Chubu University, 1200 Matsumoto-ho, Kasugai, Aihi, Japan {mishi, mtdoll}@vision.s.hubu.a.jp,

More information

Outline. CS38 Introduction to Algorithms. Administrative Stuff. Administrative Stuff. Motivation/Overview. Administrative Stuff

Outline. CS38 Introduction to Algorithms. Administrative Stuff. Administrative Stuff. Motivation/Overview. Administrative Stuff Outline CS38 Introdution to Algorithms Leture 1 April 1, 2014 administrative stuff motivation and overview of the ourse stale mathings example graphs, representing graphs graph traversals (BFS, DFS) onnetivity,

More information

Curriculum for Excellence LEVEL 3 (Book 3b)

Curriculum for Excellence LEVEL 3 (Book 3b) Note :- This sample shows the first 4 of 20 Mental tests along with their 4 Support sheets, the ontents list and a blank Pupil Reord list. Mental Mathematis Pak Curriulum for Exellene LEVEL 3 (Book 3b)

More information

Menu. X + /X=1 and XY+X /Y = X(Y + /Y) = X

Menu. X + /X=1 and XY+X /Y = X(Y + /Y) = X Menu K-Maps and Boolean Algera >Don t ares >5 Variale Look into my... 1 Karnaugh Maps - Boolean Algera We have disovered that simplifiation/minimization is an art. If you see it, GREAT! Else, work at it,

More information

System-Level Parallelism and Throughput Optimization in Designing Reconfigurable Computing Applications

System-Level Parallelism and Throughput Optimization in Designing Reconfigurable Computing Applications System-Level Parallelism and hroughput Optimization in Designing Reonfigurable Computing Appliations Esam El-Araby 1, Mohamed aher 1, Kris Gaj 2, arek El-Ghazawi 1, David Caliga 3, and Nikitas Alexandridis

More information

Incremental Mining of Partial Periodic Patterns in Time-series Databases

Incremental Mining of Partial Periodic Patterns in Time-series Databases CERIAS Teh Report 2000-03 Inremental Mining of Partial Periodi Patterns in Time-series Dataases Mohamed G. Elfeky Center for Eduation and Researh in Information Assurane and Seurity Purdue University,

More information

Lecture 13. Call Stacks & Debugging

Lecture 13. Call Stacks & Debugging Lecture 13 Call Stacks & Debugging Announcements for This Lecture Prelim 1 TONIGHT 7:30-9pm Abel Price (Upson B17) Rabbit Teo (Upson 111) Ting Zytariuk (Upson 109) Graded late tonight Will have grade Fri

More information

Announcements. Lecture Caching Issues for Multi-core Processors. Shared Vs. Private Caches for Small-scale Multi-core

Announcements. Lecture Caching Issues for Multi-core Processors. Shared Vs. Private Caches for Small-scale Multi-core Announements Your fous should be on the lass projet now Leture 17: Cahing Issues for Multi-ore Proessors This week: status update and meeting A short presentation on: projet desription (problem, importane,

More information

CS Lecture 26: Subclasses in Event-driven Programs A7 is out! Get started right away you need time to ask questions.

CS Lecture 26: Subclasses in Event-driven Programs A7 is out! Get started right away you need time to ask questions. CS 1110 Lecture 26: Subclasses in Event-driven Programs A7 is out! Get started right away you need time to ask questions. Academic integrity Please be careful: do not share your code or look at other groups

More information

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader Prelim 1 CS 2110, 14 March 2017, 7:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader The exam is closed ook and closed notes. Do not egin

More information

Lecture 9. Memory and Call Stacks

Lecture 9. Memory and Call Stacks Lecture 9 Memory and Call Stacks Announcements for Today Assignment 1 Reading We have started grading! Should have your grade tomorrow morning Resubmit until correct If you were close Will get feedback

More information

61A Lecture 3. Friday, September 5

61A Lecture 3. Friday, September 5 61A Lecture 3 Friday, September 5 Announcements There's plenty of room in live lecture if you want to come (but videos are still better) Please don't make noise outside of the previous lecture! Homework

More information

Naïve Bayes Slides are adapted from Sebastian Thrun (Udacity ), Ke Chen Jonathan Huang and H. Witten s and E. Frank s Data Mining and Jeremy Wyatt,

Naïve Bayes Slides are adapted from Sebastian Thrun (Udacity ), Ke Chen Jonathan Huang and H. Witten s and E. Frank s Data Mining and Jeremy Wyatt, Naïve Bayes Slides are adapted from Sebastian Thrun (Udaity ), Ke Chen Jonathan Huang and H. Witten s and E. Frank s Data Mining and Jeremy Wyatt, Bakground There are three methods to establish a lassifier

More information

International Journal of Advancements in Research & Technology, Volume 3, Issue 3, March-2014 ISSN

International Journal of Advancements in Research & Technology, Volume 3, Issue 3, March-2014 ISSN International Journal of Advanements in Researh & Tehnology, Volume 3, Issue 3, Marh-204 ISSN 2278-773 47 Phrase Based Doument Retrieving y Comining Suffix Tree index data struture and Boyer- Moore faster

More information

1 Introduction. Abstract

1 Introduction. Abstract Computing Faes in Segment and Simplex Arrangements (Preliminary Version) NANCY M. AMATO MICHAEL T. GOODRICH y EDGAR A. RAMOS z Texas A&M Univ. Johns Hopkins Univ. Univ. of Illinois amato@s.tamu.edu goodrih@s.jhu.edu

More information

SORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions:

SORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions: Prelim 1 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Tonigt!!!! Two Sessions: You sould now y now wat room to tae te final. Jenna

More information

A Novel Validity Index for Determination of the Optimal Number of Clusters

A Novel Validity Index for Determination of the Optimal Number of Clusters IEICE TRANS. INF. & SYST., VOL.E84 D, NO.2 FEBRUARY 2001 281 LETTER A Novel Validity Index for Determination of the Optimal Number of Clusters Do-Jong KIM, Yong-Woon PARK, and Dong-Jo PARK, Nonmembers

More information

Recap: Pointers. int* int& *p &i &*&* ** * * * * IFMP 18, M. Schwerhoff

Recap: Pointers. int* int& *p &i &*&* ** * * * * IFMP 18, M. Schwerhoff Recap: Pointers IFMP 18, M. Schwerhoff int* int& *p &i &*&* ** * * * * A 0 A 1 A 2 A 3 A 4 A 5 A 0 A 1 A 2 A 3 A 4 A 5 5 i int* p; A 0 A 1 A 2 A 3 A 4 A 5 5 i p int* p; p = &i; A 0 A 1 A 2 A 3 A 4 A 5

More information

1. Introduction. 2. The Probable Stope Algorithm

1. Introduction. 2. The Probable Stope Algorithm 1. Introdution Optimization in underground mine design has reeived less attention than that in open pit mines. This is mostly due to the diversity o underground mining methods and omplexity o underground

More information

CS Prelim 2 Review Fall 2015

CS Prelim 2 Review Fall 2015 CS 1110 Prelim 2 Review Fall 2015 Exam Info Prelim 2: 7:30 9:00PM, Thursday, Nov. 12th Last name A J in Uris G01 Last name K Z in Statler Auditorium SDS Students will get an e-mail To help you study: Study

More information

15-110: Principles of Computing, Spring 2018

15-110: Principles of Computing, Spring 2018 15-110: Principles of Computing, Spring 2018 Problem Set 5 (PS5) Due: Friday, February 23 by 2:30PM via Gradescope Hand-in HANDIN INSTRUCTIONS Download a copy of this PDF file. You have two ways to fill

More information

COMP 364: Computer Tools for Life Sciences

COMP 364: Computer Tools for Life Sciences COMP 364: Computer Tools for Life Sciences Algorithm design: Linear and Binary Search Mathieu Blanchette, based on material from Christopher J.F. Cameron and Carlos G. Oliver 1 / 24 Algorithms An algorithm

More information

A Practical Tool for Visualizing and Data Mining Medical Time Series

A Practical Tool for Visualizing and Data Mining Medical Time Series A Pratial Tool for Visualizing and Data Mining Medial Time Series Astrat The inreasing interest in time series data mining in the last deade has had surprisingly little impat on real world medial appliations.

More information

CS 1110 Final, December 9th, Question Points Score Total: 100

CS 1110 Final, December 9th, Question Points Score Total: 100 CS 1110 Final, Decemer 9th, 2015 This 150-minute exam has 8 questions worth a total of 100 points. Scan the whole test efore starting. Budget your time wisely. Use the ack of the pages if you need more

More information

Triangles. Learning Objectives. Pre-Activity

Triangles. Learning Objectives. Pre-Activity Setion 3.2 Pre-tivity Preparation Triangles Geena needs to make sure that the dek she is building is perfetly square to the brae holding the dek in plae. How an she use geometry to ensure that the boards

More information

Performance Improvement of TCP on Wireless Cellular Networks by Adaptive FEC Combined with Explicit Loss Notification

Performance Improvement of TCP on Wireless Cellular Networks by Adaptive FEC Combined with Explicit Loss Notification erformane Improvement of TC on Wireless Cellular Networks by Adaptive Combined with Expliit Loss tifiation Masahiro Miyoshi, Masashi Sugano, Masayuki Murata Department of Infomatis and Mathematial Siene,

More information

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY CS 111X - Fall 2016 - Test 1 1/9 Computing ID: CS 111X - Fall 2016 - Test 1 - KEY KEY KEY KEY KEY KEY KEY Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

On Optimal Total Cost and Optimal Order Quantity for Fuzzy Inventory Model without Shortage

On Optimal Total Cost and Optimal Order Quantity for Fuzzy Inventory Model without Shortage International Journal of Fuzzy Mathemat and Systems. ISSN 48-9940 Volume 4, Numer (014, pp. 193-01 Researh India Puliations http://www.ripuliation.om On Optimal Total Cost and Optimal Order Quantity for

More information

Conditional Control Structures. Dr.T.Logeswari

Conditional Control Structures. Dr.T.Logeswari Conditional Control Structures Dr.T.Logeswari TEST COMMAND test expression Or [ expression ] Syntax Ex: a=5; b=10 test $a eq $b ; echo $? [ $a eq $b] ; echo $? 2 Unix Shell Programming - Forouzan 2 TEST

More information

CS Lecture 19: Loop invariants

CS Lecture 19: Loop invariants CS 1110 Lecture 19: Loop invariants Announcements Prelim 2 conflicts Today (April 2) is two weeks before the prelim, and the deadline for submitting prelim conflicts. Instructor travel This week and the

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 08 Lists Constants Last Class We Covered More on while loops Sentinel loops Boolean flags 2 Any Questions from Last Time? 3 Today s Objectives To learn about

More information

8 : Learning Fully Observed Undirected Graphical Models

8 : Learning Fully Observed Undirected Graphical Models 10-708: Probabilisti Graphial Models 10-708, Spring 2018 8 : Learning Fully Observed Undireted Graphial Models Leturer: Kayhan Batmanghelih Sribes: Chenghui Zhou, Cheng Ran (Harvey) Zhang When learning

More information

Review (Law of sines and cosine) cosines)

Review (Law of sines and cosine) cosines) Date:03/7,8/01 Review 6.1-6. Objetive: Apply the onept to use the law of the sines and osines to solve oblique triangles Apply the onept to find areas using the law of sines and osines Agenda: Bell ringer

More information

CORRECTNESS ISSUES AND LOOP INVARIANTS

CORRECTNESS ISSUES AND LOOP INVARIANTS Aout A2 and feedack. Recursion 2 CORRECTNESS ISSUES AND LOOP INVARIANTS S2 has een graded. If you got 30/30, you will proaly have no feedack. If you got less than full credit, there should e feedack showing

More information

Test Case Generation from UML State Machines

Test Case Generation from UML State Machines Test Case Generation from UML State Mahines Dirk Seifert Loria Université Nany 2 Campus Sientifique, BP 239 F-54506 Vandoeuvre lès Nany edex Dirk.Seifert@Loria.fr inria-00268864, version 2-23 Apr 2008

More information

Lecture 24. GUI Applications

Lecture 24. GUI Applications Lecture 24 GUI Applications Announcements for This Lecture Prelim 2 Difficulty was reasonable Mean: 71, Median: 74 Just 2 points below target What do grades mean? A: 80s+ (maybe 78+) B: 60s+ C: 30+ Final

More information

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY 1 A3 and Prelim 2 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Fall 2016 Deadline for A3: tonight. Only two late days allowed (Wed-Thur) Prelim: Thursday evening. 74 conflicts! If you

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

A Partial Sorting Algorithm in Multi-Hop Wireless Sensor Networks

A Partial Sorting Algorithm in Multi-Hop Wireless Sensor Networks A Partial Sorting Algorithm in Multi-Hop Wireless Sensor Networks Abouberine Ould Cheikhna Department of Computer Siene University of Piardie Jules Verne 80039 Amiens Frane Ould.heikhna.abouberine @u-piardie.fr

More information

Basic Techniques. Recursion. Today: Later on: Recursive methods who call themselves directly or indirectly.

Basic Techniques. Recursion. Today: Later on: Recursive methods who call themselves directly or indirectly. La 2 Recursion Basic Techniques SMD135 Programs and Data Structures Lecture 7 Sorting: Divide-and- Conquer Brute force Selection sort Insertion sort Linear proing [seaching through an unordered array]

More information

Grade 6. Mathematics. Student Booklet SPRING 2009 RELEASED ASSESSMENT QUESTIONS. Assessment of Reading, Writing and Mathematics, Junior Division

Grade 6. Mathematics. Student Booklet SPRING 2009 RELEASED ASSESSMENT QUESTIONS. Assessment of Reading, Writing and Mathematics, Junior Division Grade 6 Assessment of Reading, Writing and Mathematis, Junior Division Student Booklet Mathematis SPRING 2009 RELEASED ASSESSMENT QUESTIONS Please note: The format of these booklets is slightly different

More information

CompSci 101 Introduction to Computer Science

CompSci 101 Introduction to Computer Science CompSci 101 Introduction to Computer Science score = [10,8,10,9] Feb. 7, 2017 Prof. Rodger compsci 101, spring17 1 Announcements Reading and RQ8 due next time Assignment 3 due tonight Assignment 4 out,

More information

CS Prelim 1 Review Fall 2017

CS Prelim 1 Review Fall 2017 CS 1110 Prelim 1 Review Fall 2017 Exam Info Prelim 1: 7:30 9:00PM, Thursday, October 12th Last name A J in Uris G01 Last name K Z in Statler Auditorium SDS Students will get an e-mail To help you study:

More information

Hash-Based Indexes. Chapter 11

Hash-Based Indexes. Chapter 11 Hash-Based Indexes Chapter 11 1 Introduction : Hash-based Indexes Best for equality selections. Cannot support range searches. Static and dynamic hashing techniques exist: Trade-offs similar to ISAM vs.

More information

O Type of array element

O Type of array element ! " #! $ % % # & : ; a ontiguous sequene of variables. all of the sae type. Eah variable is identified by its index. Index values are integers. Index of first entry is. ' ( ) * + May /,. - ( & ( ( J K

More information

Multi-Level Modeling of Concurrent and Distributed Systems

Multi-Level Modeling of Concurrent and Distributed Systems Multi-Level Modeling of Conurrent and Distriuted Systems Peter Taeling Hasso-Plattner-Institute for Software Systems Engineering P.O. Box 90 04 60, 14440 Potsdam, Germany taeling@hpi.uni-potsdam.de strat

More information

CS 1110: Introduction to Computing Using Python Loop Invariants

CS 1110: Introduction to Computing Using Python Loop Invariants CS 1110: Introduction to Computing Using Python Lecture 21 Loop Invariants [Andersen, Gries, Lee, Marschner, Van Loan, White] Announcements Prelim 2 conflicts due by midnight tonight Lab 11 is out Due

More information

Path Sharing and Predicate Evaluation for High-Performance XML Filtering*

Path Sharing and Predicate Evaluation for High-Performance XML Filtering* Path Sharing and Prediate Evaluation for High-Performane XML Filtering Yanlei Diao, Mihael J. Franklin, Hao Zhang, Peter Fisher EECS, University of California, Berkeley {diaoyl, franklin, nhz, fisherp}@s.erkeley.edu

More information

CS Prelim 2 Review Fall 2014

CS Prelim 2 Review Fall 2014 CS 1110 Prelim 2 Review Fall 2014 Exam Info Prelim 2: 7:30 9:00PM, Thursday, Nov. 13th Last name A Sh in Statler Auditorium Last name Si X in Statler 196 Last name Y Z in Statler 198 SDS Students will

More information

MERGESORT & QUICKSORT cs2420 Introduction to Algorithms and Data Structures Spring 2015

MERGESORT & QUICKSORT cs2420 Introduction to Algorithms and Data Structures Spring 2015 MERGESORT & QUICKSORT cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 4 due tonight at midnight -assignment 5 is out -midterm next Tuesday 3 last time 4

More information

Total 100

Total 100 CS331 SOLUTION Problem # Points 1 10 2 15 3 25 4 20 5 15 6 15 Total 100 1. ssume you are dealing with a ompiler for a Java-like language. For eah of the following errors, irle whih phase would normally

More information

Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University

Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University Binary Decision Diagrams (BDDs) Pingqiang Zhou ShanghaiTech University Computational Boolean Algera Representations Applying unate recursive paradigm (URP) in solving tautology is a great warm up example.

More information

PathRings. Manual. Version 1.0. Yongnan Zhu December 16,

PathRings. Manual. Version 1.0. Yongnan Zhu   December 16, PathRings Version 1.0 Manual Yongnan Zhu E-mail: yongnan@umb.edu Deember 16, 2014-1 - PathRings This tutorial introdues PathRings, the user interfae and the interation. For better to learn, you will need

More information

Z Combinatorial Filters: Sensor Beams, Obstacles, and Possible Paths

Z Combinatorial Filters: Sensor Beams, Obstacles, and Possible Paths Z Combinatorial Filters: Sensor Beams, Obstales, and Possible Paths BENJAMIN TOVAR, Northwestern University FRED COHEN, University of Rohester LEONARDO BOBADILLA, University of Illinois JUSTIN CZARNOWSKI,

More information