Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Size: px
Start display at page:

Download "Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved."

Transcription

1

2 Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

3 Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig 5.5 Geeral Debuggig Techiques Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-3

4 5.1 void Fuctios Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

5 void-fuctios I top-dow desig, a subtask might produce No value (just iput or output for example) Oe value More tha oe value We have see how to implemet fuctios that retur oe value A void-fuctio implemets a subtask that returs o value or more tha oe value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-5

6 void-fuctio Defiitio Two mai differeces betwee void-fuctio defiitios ad the defiitios of fuctios that retur oe value Keyword void replaces the type of the value retured void meas that o value is retured by the fuctio The retur statemet does ot iclude ad expressio Example: void show_results(double f_degrees, double c_degrees) { usig amespace std; cout << f_degrees << degrees Fahreheit is euivalet to << edl << c_degrees << degrees Celsius. << edl; retur; } Display 5.1 Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-6

7 Usig a void-fuctio void-fuctio calls are executable statemets They do ot eed to be part of aother statemet They ed with a semi-colo Example: show_results(32.5, 0.3); NOT: cout << show_results(32.5, 0.3); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-7

8 void-fuctio Calls Mechaism is early the same as the fuctio calls we have see Argumet values are substituted for the formal parameters It is fairly commo to have o parameters i void-fuctios I this case there will be o argumets i the fuctio call Statemets i fuctio body are executed Optioal retur statemet eds the fuctio Retur statemet does ot iclude a value to retur Retur statemet is implicit if it is ot icluded Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-8

9 Example: Covertig Temperatures The fuctios just developed ca be used i a program to covert Fahreheit temperatures to Celcius usig the formula C = (5/9) (F 32) Do you see the iteger divisio problem? Display 5.2 (1) Display 5.2 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-9

10 void-fuctios Why Use a Retur? Is a retur-statemet ever eeded i a void-fuctio sice o value is retured? Yes! What if a brach of a if-else statemet requires that the fuctio eds to avoid producig more output, or creatig a mathematical error? void-fuctio i Display 5.3, avoids divisio by zero with a retur statemet Display 5.3 Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-10

11 The Mai Fuctio The mai fuctio i a program is used like a void fuctio do you have to ed the program with a retur-statemet? Because the mai fuctio is defied to retur a value of type it, the retur is eeded C++ stadard says the retur 0 ca be omitted, but may compilers still require it Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-11

12 Sectio 5.1 Coclusio Ca you Describe the differeces betwee voidfuctios ad fuctios that retur oe value? Tell what happes if you forget the returstatemeti a void-fuctio? Distiguish betwee fuctios that are used as expressios ad those used as statemets? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-12

13 5.2 Call-By-Referece Parameters Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

14 Call-by-Referece Parameters Call-by-value is ot adequate whe we eed a sub-task to obtai iput values Call-by-value meas that the formal parameters receive the values of the argumets To obtai iput values, we eed to chage the variables that are argumets to the fuctio Recall that we have chaged the values of formal parameters i a fuctio body, but we have ot chaged the argumets foud i the fuctio call Call-by-referece parameters allow us to chage the variable used i the fuctio call Argumets for call-by-referece parameters must be variables, ot umbers Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-14

15 Call-by-Referece Example void get_iput(double& f_variable) { usig amespace std; cout << Covert a Fahreheit temperature << to Celsius.\ << Eter a temperature i Fahreheit: ; ci >> f_variable; } & symbol (ampersad) idetifies f_variable as a call-by-referece parameter Used i both declaratio ad defiitio! Display 5.4 (1) Display 5.4 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-15

16 Call-By-Referece Details Call-by-referece works almost as if the argumet variable is substituted for the formal parameter, ot the argumet s value I reality, the memory locatio of the argumet variable is give to the formal parameter Whatever is doe to a formal parameter i the fuctio body, is actually doe to the value at the memory locatio of the argumet variable Display 5.5 (1) Display 5.5 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-16

17 Call Comparisos Call By Referece vs Value Call-by-referece The fuctio call: f(age); Memory Name Locatio Cotets Call-by-value The fuctio call: f(age); age iitial 1002 A hours void f(it& ref_par); void f(it var_par); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-17

18 Example: swap_values void swap(it& variable1, it& variable2) { it temp = variable1; variable1 = variable2; variable2 = temp; } If called with swap(first_um, secod_um); first_um is substituted for variable1 i the parameter list secod_um is substituted for variable2 i the parameter list temp is assiged the value of variable1 (first_um) sice the ext lie will loose the value i first_um variable1 (first_um) is assiged the value i variable2 (secod_um) variable2 (secod_um) is assiged the origial value of variable1 (first_um) which was stored i temp Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-18

19 Mixed Parameter Lists Call-by-value ad call-by-referece parameters ca be mixed i the same fuctio Example: void good_stuff(it& par1, it par2, double& par3); par1 ad par3 are call-by-referece formal parameters Chages i par1 ad par3 chage the argumet variable par2 is a call-by-value formal parameter Chages i par2 do ot chage the argumet variable Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-19

20 Choosig Parameter Types How do you decide whether a call-by-referece or call-by-value formal parameter is eeded? Does the fuctio eed to chage the value of the variable used as a argumet? Yes? Use a call-by-referece formal parameter No? Use a call-by-value formal parameter Display 5.6 Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-20

21 Iadvertet Local Variables If a fuctio is to chage the value of a variable the correspodig formal parameter must be a call-by-referece parameter with a ampersad (&) attached Forgettig the ampersad (&) creates a call-by-value parameter The value of the variable will ot be chaged The formal parameter is a local variable that has o effect outside the fuctio Hard error to fid it looks right! Display 5.7 Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-21

22 Sectio 5.2 Coclusio Ca you Write a void-fuctio defiitio for a fuctio called zero_both that has two referece parameters, both of which are variables of type it, ad sets the values of both variables to 0. Write a fuctio that returs a value ad has a call-by-referece parameter? Write a fuctio with both call-by-value ad call-by-referece parameters Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-22

23 5.3 Usig Procedural Abstractio Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

24 Usig Procedural Abstractio Fuctios should be desiged so they ca be used as black boxes To use a fuctio, the declaratio ad commet should be sufficiet Programmer should ot eed to kow the details of the fuctio to use it Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-24

25 Fuctios Callig Fuctios A fuctio body may cotai a call to aother fuctio The called fuctio declaratio must still appear before it is called Fuctios caot be defied i the body of aother fuctio Example: void order(it& 1, it& 2) { if (1 > 2) swap_values(1, 2); } swap_values called if 1 ad 2 are ot i ascedig order After the call to order, 1 ad 2 are i ascedig order Display 5.8 (1) Display 5.8 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-25

26 Pre ad Postcoditios Precoditio States what is assumed to be true whe the fuctio is called Fuctio should ot be used uless the precoditio holds Postcoditio Describes the effect of the fuctio call Tells what will be true after the fuctio is executed (whe the precoditio holds) If the fuctio returs a value, that value is described Chages to call-by-referece parameters are described Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-26

27 swap_values revisited Usig precoditios ad postcoditios the declaratio of swap_values becomes: void swap_values(it& 1, it& 2); //Precoditio: variable1 ad variable 2 have // bee give values // Postcoditio: The values of variable1 ad // variable2 have bee // iterchaged Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-27

28 Fuctio celsius Precoditios ad postcoditios make the declaratio for celsius: double celsius(double fareheit); //Precoditio: fahreheit is a temperature // expressed i degrees Fahreheit //Postcoditio: Returs the equivalet temperature // expressed i degrees Celsius Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-28

29 Why use precoditios ad postcoditios? Precoditios ad postcoditios should be the first step i desigig a fuctio specify what a fuctio should do Always specify what a fuctio should do before desigig how the fuctio will do it Miimize desig errors Miimize time wasted writig code that does t match the task at had Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-29

30 Case Study Supermarket Pricig Problem defiitio Determie retail price of a item give suitable iput 5% markup if item should sell i a week 10% markup if item expected to take more tha a week Iput 5% for up to 7 days, chages to 10% at 8 days The wholesale price ad the estimate of days util item sells Output The retail price of the item Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-30

31 Supermarket Pricig: Problem Aalysis Three mai subtasks Iput the data Compute the retail price of the item Output the results Each task ca be implemeted with a fuctio Notice the use of call-by-value ad call-by-referece parameters i the followig fuctio declaratios Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-31

32 Supermarket Pricig: Fuctio get_iput void get_iput(double& cost, it& turover); //Precoditio: User is ready to eter values // correctly. //Postcoditio: The value of cost has bee set to // the wholesale cost of oe item. // The value of turover has bee // set to the expected umber of // days util the item is sold. Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-32

33 Supermarket Pricig: Fuctio price double price(double cost, it turover); //Precoditio: cost is the wholesale cost of oe // item. turover is the expected // umber of days util the item is // sold. //Postcoditio: returs the retail price of the item Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-33

34 Supermarket Pricig: Fuctio give_output void give_output(double cost, it turover, double price); //Precoditio: cost is the wholesale cost of oe item; // turover is the expected time util sale // of the item; price is the retail price of // the item. //Postcoditio: The values of cost, turover, ad price // bee writte to the scree. Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-34

35 Supermarket Pricig: The mai fuctio With the fuctios declared, we ca write the mai fuctio: it mai() { double wholesale_cost, retail_price; it shelf_time; get_iput(wholesale_cost, shelf_time); retail_price = price(wholesale_cost, shelf_time); give_output(wholesale_cost, shelf_time, retail_price); retur 0; } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-35

36 Supermarket Pricig: Algorithm Desig -- price Implemetatios of get_iput ad give_output are straightforward, so we cocetrate o the price fuctio pseudocode for the price fuctio If turover <= 7 days the retur (cost + 5% of cost); else retur (cost + 10% of cost); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-36

37 Supermarket Pricig: Costats for The price Fuctio The umeric values i the pseudocode will be represeted by costats Cost double LOW_MARKUP = 0.05; // 5% Cost double HIGH_MARKUP = 0.10; // 10% Cost it THRESHOLD = 7; // At 8 days use //HIGH_MARKUP Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-37

38 Supermarket Pricig: Codig The price Fuctio The body of the price fuctio { if (turover <= THRESHOLD) retur ( cost + (LOW_MARKUP * cost) ) ; else retur ( cost + ( HIGH_MARKUP * cost) ) ; } Display 5.9 (1) See the complete program i Display 5.9 (2) Display 5.9 (3) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-38

39 Supermarket Pricig : Program Testig Testig strategies Use data that tests both the high ad low markup cases Test boudary coditios, where the program is expected to chage behavior or make a choice I fuctio price, 7 days is a boudary coditio Test for exactly 7 days as well as oe day more ad oe day less Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-39

40 Sectio 5.3 Coclusio Ca you Defie a fuctio i the body of aother fuctio? Call oe fuctio from the body of aother fuctio? Give precoditios ad postcoditios for the predefied fuctio sqrt? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-40

41 5.4 Testig ad Debuggig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

42 Testig ad Debuggig Fuctios Each fuctio should be tested as a separate uit Testig idividual fuctios facilitates fidig mistakes Driver programs allow testig of idividual fuctios Oce a fuctio is tested, it ca be used i the driver program to test other fuctios Fuctio get_iput is tested i the driver program of ad Display 5.10 (1) Display 5.10 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-42

43 Stubs Whe a fuctio beig tested calls other fuctios that are ot yet tested, use a stub A stub is a simplified versio of a fuctio Stubs are usually provide values for testig rather tha perform the iteded calculatio Stubs should be so simple that you have cofidece they will perform correctly Fuctio price is used as a stub to test the rest of the supermarket pricig program i ad Display 5.11 (1) Display 5.11 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-43

44 Rule for Testig Fuctios Fudametal Rule for Testig Fuctios Test every fuctio i a program i which every other fuctio i that program has already bee fully tested ad debugged. Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-44

45 Sectio 5.4 Coclusio Ca you Describe the fudametal rule for testig fuctios? Describe a driver program? Write a driver program to test a fuctio? Describe ad use a stub? Write a stub? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-45

46 5.5 Geeral Debuggig Techiques Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

47 Geeral Debuggig Techiques Stubs, drivers, test cases as described i the previous sectio Keep a ope mid Do t assume the bug is i a particular locatio Do t radomly chage code without uderstadig what you are doig util the program works This strategy may work for the first few small programs you write but is doomed to failure for ay programs of moderate complexity Show the program to someoe else Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-47

48 Geeral Debuggig Techiques Check for commo errors, e.g. Local vs. Referece Parameter = istead of == Localize the error This temperature coversio program has a bug Display 5.12 Narrow dow bug usig cout statemets Display 5.13 Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 1-48

49 Geeral Debuggig Techiques Use a debugger Tool typically itegrated with a developmet eviromet that allows you to stop ad step through a program lie-by-lie while ispectig variables The assert macro Ca be used to test pre or post coditios #iclude <cassert> assert(boolea expressio) If the boolea is false the the program will abort Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-49

50 Assert Example Deomiator should ot be zero i Newto s Method Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-50

51 Sectio 5.5 Coclusio Ca you Recogize commo errors? Use the assert macro? Debug a program usig cout statemets to localize the error? Debug a program usig a debugger? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-51

52 Chapter 5 -- Ed Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-52

53 Display 5.1 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-53

54 Display 5.2 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-54

55 Display 5.2 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-55

56 Display 5.3 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-56

57 Display 5.4 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-57

58 Display 5.4 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-58

59 Display 5.5 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-59

60 Display 5.5 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-60

61 Display 5.6 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-61

62 Display 5.7 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-62

63 Display 5.8 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-63

64 Display 5.8 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-64

65 Display 5.9 (1/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-65

66 Display 5.9 (2/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-66

67 Display 5.9 (3/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-67

68 Display 5.10 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-68

69 Display 5.10 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-69

70 Display 5.11 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-70

71 Display 5.11 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-71

72 Display 5.12 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-72

73 Display 5.13 (1 of 2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-73

74 Display 5.13 (2 of 2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 5-74

Chapter void Functions. Overview. Functions for All Subtasks. void-functions. Using a void-function. void-function Definition

Chapter void Functions. Overview. Functions for All Subtasks. void-functions. Using a void-function. void-function Definition Chapter 5 Functions for All Subtasks Overview 5.1 void Functions 5.2 Call-By-Reference Parameters 5.3 Using Procedural Abstraction 5.4 Testing and Debugging 5.5 General Debugging Techniques Copyright 2011

More information

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

Call- by- Reference Func0ons Procedural Abstrac0ons Numerical Conversions CS 16: Solving Problems with Computers I Lecture #9

Call- by- Reference Func0ons Procedural Abstrac0ons Numerical Conversions CS 16: Solving Problems with Computers I Lecture #9 Call- by- Reference Func0ons Procedural Abstrac0ons Numerical Conversions CS 16: Solving Problems with Computers I Lecture #9 Ziad Matni Dept. of Computer Science, UCSB Announcements Homework #8 due today

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,

More information

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 8 Strigs ad Vectors Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Copyright 2015 Pearso Educatio, Ltd..

More information

CS 11 C track: lecture 1

CS 11 C track: lecture 1 CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 3 More Flow of Cotrol Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 3.1 Usig Boolea Expressios 3.2 Multiway Braches 3.3 More about C++ Loop Statemets 3.4 Desigig Loops Copyright

More information

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 8 Strigs ad Vectors Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Slide 8-3 8.1 A Array Type for Strigs A Array Type for Strigs C-strigs ca be used to represet strigs

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

n Maurice Wilkes, 1949 n Organize software to minimize errors. n Eliminate most of the errors we made anyway.

n Maurice Wilkes, 1949 n Organize software to minimize errors. n Eliminate most of the errors we made anyway. Bjare Stroustrup www.stroustrup.com/programmig Chapter 5 Errors Abstract Whe we program, we have to deal with errors. Our most basic aim is correctess, but we must deal with icomplete problem specificatios,

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 2 C++ Basics Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 2.1 Variables ad Assigmets 2.2 Iput ad Output 2.3 Data Types ad Expressios 2.4 Simple Flow of Cotrol 2.5 Program

More information

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig

More information

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June CS 1313 010: Programmig for No-Majors, Summer 2007 Programmig Project #3: Two Little Calculatios Due by 12:00pm (oo) Wedesday Jue 27 2007 This third assigmet will give you experiece writig programs that

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The

More information

Data Structures and Algorithms. Analysis of Algorithms

Data Structures and Algorithms. Analysis of Algorithms Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then UCLA PIC 10 B Problem Solvig usig C++ Programmig Ivo Diov, Asst. Prof. i Mathematics, Neurology, Statistics Istructor: Teachig Assistat: Suzae Nezzar, Mathematics Chapter 13 Templates for More Abstractio

More information

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis

More information

Chapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 6 I/O Streams as a Itroductio to Objects ad Classes Overview 6.1 Streams ad Basic File I/O 6.2 Tools for Stream I/O 6.3 Character I/O Slide 6-3 6.1 Streams ad Basic File I/O I/O Streams I/O refers

More information

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

Definitions. Error. A wrong decision made during software development

Definitions. Error. A wrong decision made during software development Debuggig Defiitios Error A wrog decisio made durig software developmet Defiitios 2 Error A wrog decisio made durig software developmet Defect bug sometimes meas this The term Fault is also used Property

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen COP4020 Programmig Laguages Subrouties ad Parameter Passig Prof. Robert va Egele Overview Parameter passig modes Subroutie closures as parameters Special-purpose parameters Fuctio returs COP4020 Fall 2016

More information

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of

More information

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup   Note: Chapter 4 Computatio Bjare Stroustrup www.stroustrup.com/programmig Abstract Today, I ll preset the basics of computatio. I particular, we ll discuss expressios, how to iterate over a series of values

More information

CMPT 125 Assignment 2 Solutions

CMPT 125 Assignment 2 Solutions CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address

More information

From last week. Lecture 5. Outline. Principles of programming languages

From last week. Lecture 5. Outline. Principles of programming languages Priciples of programmig laguages From last week Lecture 5 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for

More information

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:

More information

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers?

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers? CSE401: Itroductio to Compiler Costructio Larry Ruzzo Sprig 2004 Today s objectives Admiistrative details Defie compilers ad why we study them Defie the high-level structure of compilers Associate specific

More information

1.8 What Comes Next? What Comes Later?

1.8 What Comes Next? What Comes Later? 35 1.8 What Comes Next? What Comes Later? A Practice Uderstadig Task For each of the followig tables, CC BY Hiroaki Maeda https://flic.kr/p/6r8odk describe how to fid the ext term i the sequece, write

More information

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method A ew Morphological 3D Shape Decompositio: Grayscale Iterframe Iterpolatio Method D.. Vizireau Politehica Uiversity Bucharest, Romaia ae@comm.pub.ro R. M. Udrea Politehica Uiversity Bucharest, Romaia mihea@comm.pub.ro

More information

C++ Basics - 3 Rahul

C++ Basics - 3 Rahul C++ Basics - 3 Rahul Deodhar @rahuldeodhar www.rahuldeodhar.com rahuldeodhar@gmail.com Topics for today Func@ons Classwork Topics for today Homework Program Others Procedural Abstrac@on & Func@ons Top

More information

The VSS CCD photometry spreadsheet

The VSS CCD photometry spreadsheet The VSS CCD photometry spreadsheet Itroductio This Excel spreadsheet has bee developed ad tested by the BAA VSS for aalysig results files produced by the multi-image CCD photometry procedure i AIP4Wi v2.

More information

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures Uiversity of Waterloo Departmet of Electrical ad Computer Egieerig ECE 250 Algorithms ad Data Structures Midterm Examiatio ( pages) Istructor: Douglas Harder February 7, 2004 7:30-9:00 Name (last, first)

More information

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000. 5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator

More information

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0 Polyomial Fuctios ad Models 1 Learig Objectives 1. Idetify polyomial fuctios ad their degree 2. Graph polyomial fuctios usig trasformatios 3. Idetify the real zeros of a polyomial fuctio ad their multiplicity

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programmig Laguages Fuctioal Programmig Prof. Robert va Egele Overview What is fuctioal programmig? Historical origis of fuctioal programmig Fuctioal programmig today Cocepts of fuctioal programmig

More information

IMP: Superposer Integrated Morphometrics Package Superposition Tool

IMP: Superposer Integrated Morphometrics Package Superposition Tool IMP: Superposer Itegrated Morphometrics Package Superpositio Tool Programmig by: David Lieber ( 03) Caisius College 200 Mai St. Buffalo, NY 4208 Cocept by: H. David Sheets, Dept. of Physics, Caisius College

More information

Floristic Quality Assessment (FQA) Calculator for Colorado User s Guide

Floristic Quality Assessment (FQA) Calculator for Colorado User s Guide Floristic Quality Assessmet (FQA) Calculator for Colorado User s Guide Created by the Colorado atural Heritage Program Last Updated April 2012 The FQA Calculator was created by Michelle Fik ad Joaa Lemly

More information

Algorithm. Counting Sort Analysis of Algorithms

Algorithm. Counting Sort Analysis of Algorithms Algorithm Coutig Sort Aalysis of Algorithms Assumptios: records Coutig sort Each record cotais keys ad data All keys are i the rage of 1 to k Space The usorted list is stored i A, the sorted list will

More information

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control EE 459/500 HDL Based Digital Desig with Programmable Logic Lecture 13 Cotrol ad Sequecig: Hardwired ad Microprogrammed Cotrol Refereces: Chapter s 4,5 from textbook Chapter 7 of M.M. Mao ad C.R. Kime,

More information

Parabolic Path to a Best Best-Fit Line:

Parabolic Path to a Best Best-Fit Line: Studet Activity : Fidig the Least Squares Regressio Lie By Explorig the Relatioship betwee Slope ad Residuals Objective: How does oe determie a best best-fit lie for a set of data? Eyeballig it may be

More information

COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen

COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen COP4020 mig Laguages Compilers ad Iterpreters Prof. Robert va Egele Overview Commo compiler ad iterpreter cofiguratios Virtual machies Itegrated developmet eviromets Compiler phases Lexical aalysis Sytax

More information

SD vs. SD + One of the most important uses of sample statistics is to estimate the corresponding population parameters.

SD vs. SD + One of the most important uses of sample statistics is to estimate the corresponding population parameters. SD vs. SD + Oe of the most importat uses of sample statistics is to estimate the correspodig populatio parameters. The mea of a represetative sample is a good estimate of the mea of the populatio that

More information

EVALUATION OF TRIGONOMETRIC FUNCTIONS

EVALUATION OF TRIGONOMETRIC FUNCTIONS EVALUATION OF TRIGONOMETRIC FUNCTIONS Whe first exposed to trigoometric fuctios i high school studets are expected to memorize the values of the trigoometric fuctios of sie cosie taget for the special

More information

Performance Plus Software Parameter Definitions

Performance Plus Software Parameter Definitions Performace Plus+ Software Parameter Defiitios/ Performace Plus Software Parameter Defiitios Chapma Techical Note-TG-5 paramete.doc ev-0-03 Performace Plus+ Software Parameter Defiitios/2 Backgroud ad Defiitios

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

Term Project Report. This component works to detect gesture from the patient as a sign of emergency message and send it to the emergency manager.

Term Project Report. This component works to detect gesture from the patient as a sign of emergency message and send it to the emergency manager. CS2310 Fial Project Loghao Li Term Project Report Itroductio I this project, I worked o expadig exercise 4. What I focused o is makig the real gesture recogizig sesor ad desig proper gestures ad recogizig

More information

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle:

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle: Recursio Recursio Jordi Cortadella Departmet of Computer Sciece Priciple: Reduce a complex problem ito a simpler istace of the same problem Recursio Itroductio to Programmig Dept. CS, UPC 2 Mathematical

More information

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only Edited: Yeh-Liag Hsu (998--; recommeded: Yeh-Liag Hsu (--9; last updated: Yeh-Liag Hsu (9--7. Note: This is the course material for ME55 Geometric modelig ad computer graphics, Yua Ze Uiversity. art of

More information

9 x and g(x) = 4. x. Find (x) 3.6. I. Combining Functions. A. From Equations. Example: Let f(x) = and its domain. Example: Let f(x) = and g(x) = x x 4

9 x and g(x) = 4. x. Find (x) 3.6. I. Combining Functions. A. From Equations. Example: Let f(x) = and its domain. Example: Let f(x) = and g(x) = x x 4 1 3.6 I. Combiig Fuctios A. From Equatios Example: Let f(x) = 9 x ad g(x) = 4 f x. Fid (x) g ad its domai. 4 Example: Let f(x) = ad g(x) = x x 4. Fid (f-g)(x) B. From Graphs: Graphical Additio. Example:

More information

Customer Portal Quick Reference User Guide

Customer Portal Quick Reference User Guide Customer Portal Quick Referece User Guide Overview This user guide is iteded for FM Approvals customers usig the Approval Iformatio Maagemet (AIM) customer portal to track their active projects. AIM is

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

Programmer-Defined Functions

Programmer-Defined Functions Functions Programmer-Defined Functions Local Variables in Functions Overloading Function Names void Functions, Call-By-Reference Parameters in Functions Programmer-Defined Functions function declaration

More information

NTH, GEOMETRIC, AND TELESCOPING TEST

NTH, GEOMETRIC, AND TELESCOPING TEST NTH, GEOMETRIC, AND TELESCOPING TEST Sectio 9. Calculus BC AP/Dual, Revised 08 viet.dag@humbleisd.et /4/08 0:0 PM 9.: th, Geometric, ad Telescopig Test SUMMARY OF TESTS FOR SERIES Lookig at the first few

More information

Creating Test Harnesses and Starter Applications

Creating Test Harnesses and Starter Applications 03 6000 ch02 11/18/03 8:54 AM Page 27 Creatig Test Haresses ad Starter Applicatios Applicatio Types You Ca Create with Visual C++ Visual C++.NET comes with a package of wizards that geerate startig code

More information

ENGI 4421 Probability and Statistics Faculty of Engineering and Applied Science Problem Set 1 Descriptive Statistics

ENGI 4421 Probability and Statistics Faculty of Engineering and Applied Science Problem Set 1 Descriptive Statistics ENGI 44 Probability ad Statistics Faculty of Egieerig ad Applied Sciece Problem Set Descriptive Statistics. If, i the set of values {,, 3, 4, 5, 6, 7 } a error causes the value 5 to be replaced by 50,

More information

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates

More information

CIS 121. Introduction to Trees

CIS 121. Introduction to Trees CIS 121 Itroductio to Trees 1 Tree ADT Tree defiitio q A tree is a set of odes which may be empty q If ot empty, the there is a distiguished ode r, called root ad zero or more o-empty subtrees T 1, T 2,

More information

UNIT 4 Section 8 Estimating Population Parameters using Confidence Intervals

UNIT 4 Section 8 Estimating Population Parameters using Confidence Intervals UNIT 4 Sectio 8 Estimatig Populatio Parameters usig Cofidece Itervals To make ifereces about a populatio that caot be surveyed etirely, sample statistics ca be take from a SRS of the populatio ad used

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Ruig Time of a algorithm Ruig Time Upper Bouds Lower Bouds Examples Mathematical facts Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

Behavioral Modeling in Verilog

Behavioral Modeling in Verilog Behavioral Modelig i Verilog COE 202 Digital Logic Desig Dr. Muhamed Mudawar Kig Fahd Uiversity of Petroleum ad Mierals Presetatio Outlie Itroductio to Dataflow ad Behavioral Modelig Verilog Operators

More information

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1 Classes ad Objects jvo@ualg.pt José Valete de Oliveira 4-1 Agai: Distace betwee poits withi the first quadrat Sample iput Sample output 1 1 3 4 2 jvo@ualg.pt José Valete de Oliveira 4-2 1 The simplest

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Evaluation scheme for Tracking in AMI

Evaluation scheme for Tracking in AMI A M I C o m m u i c a t i o A U G M E N T E D M U L T I - P A R T Y I N T E R A C T I O N http://www.amiproject.org/ Evaluatio scheme for Trackig i AMI S. Schreiber a D. Gatica-Perez b AMI WP4 Trackig:

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS) CSC165H1, Witer 018 Learig Objectives By the ed of this worksheet, you will: Aalyse the ruig time of fuctios cotaiig ested loops. 1. Nested loop variatios. Each of the followig fuctios takes as iput a

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

Big-O Analysis. Asymptotics

Big-O Analysis. Asymptotics Big-O Aalysis 1 Defiitio: Suppose that f() ad g() are oegative fuctios of. The we say that f() is O(g()) provided that there are costats C > 0 ad N > 0 such that for all > N, f() Cg(). Big-O expresses

More information

Lecture 18. Optimization in n dimensions

Lecture 18. Optimization in n dimensions Lecture 8 Optimizatio i dimesios Itroductio We ow cosider the problem of miimizig a sigle scalar fuctio of variables, f x, where x=[ x, x,, x ]T. The D case ca be visualized as fidig the lowest poit of

More information

WORKED EXAMPLE 7.1. Producing a Mass Mailing. We want to automate the process of producing mass mailings. A typical letter might look as follows:

WORKED EXAMPLE 7.1. Producing a Mass Mailing. We want to automate the process of producing mass mailings. A typical letter might look as follows: Worked Example 7.1 Producig a Mass Mailig 1 WORKED EXAMPLE 7.1 Producig a Mass Mailig We wat to automate the process of producig mass mailigs. A typical letter might look as follows: To: Ms. Sally Smith

More information

EM375 STATISTICS AND MEASUREMENT UNCERTAINTY LEAST SQUARES LINEAR REGRESSION ANALYSIS

EM375 STATISTICS AND MEASUREMENT UNCERTAINTY LEAST SQUARES LINEAR REGRESSION ANALYSIS EM375 STATISTICS AND MEASUREMENT UNCERTAINTY LEAST SQUARES LINEAR REGRESSION ANALYSIS I this uit of the course we ivestigate fittig a straight lie to measured (x, y) data pairs. The equatio we wat to fit

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 18 Strategies for Query Processig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio DBMS techiques to process a query Scaer idetifies

More information

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions CS 111: Program Desig I Lecture # 7: First Loop, Web Crawler, Fuctios Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago September 18, 2018 What will this prit? x = 5 if x == 3: prit("hi!")

More information

Fundamentals of Media Processing. Shin'ichi Satoh Kazuya Kodama Hiroshi Mo Duy-Dinh Le

Fundamentals of Media Processing. Shin'ichi Satoh Kazuya Kodama Hiroshi Mo Duy-Dinh Le Fudametals of Media Processig Shi'ichi Satoh Kazuya Kodama Hiroshi Mo Duy-Dih Le Today's topics Noparametric Methods Parze Widow k-nearest Neighbor Estimatio Clusterig Techiques k-meas Agglomerative Hierarchical

More information

Math 3201 Notes Chapter 4: Rational Expressions & Equations

Math 3201 Notes Chapter 4: Rational Expressions & Equations Learig Goals: See p. tet.. Equivalet Ratioal Epressios ( classes) Read Goal p. 6 tet. Math 0 Notes Chapter : Ratioal Epressios & Equatios. Defie ad give a eample of a ratioal epressio. p. 6. Defie o-permissible

More information

Weston Anniversary Fund

Weston Anniversary Fund Westo Olie Applicatio Guide 2018 1 This guide is desiged to help charities applyig to the Westo to use our olie applicatio form. The Westo is ope to applicatios from 5th Jauary 2018 ad closes o 30th Jue

More information

Creating Exact Bezier Representations of CST Shapes. David D. Marshall. California Polytechnic State University, San Luis Obispo, CA , USA

Creating Exact Bezier Representations of CST Shapes. David D. Marshall. California Polytechnic State University, San Luis Obispo, CA , USA Creatig Exact Bezier Represetatios of CST Shapes David D. Marshall Califoria Polytechic State Uiversity, Sa Luis Obispo, CA 93407-035, USA The paper presets a method of expressig CST shapes pioeered by

More information

OCR Statistics 1. Working with data. Section 3: Measures of spread

OCR Statistics 1. Working with data. Section 3: Measures of spread Notes ad Eamples OCR Statistics 1 Workig with data Sectio 3: Measures of spread Just as there are several differet measures of cetral tedec (averages), there are a variet of statistical measures of spread.

More information

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion Aoucemets HW6 due today HW7 is out A team assigmet Submitty page will be up toight Fuctioal correctess: 75%, Commets : 25% Last class Equality testig eq? vs. equal? Higher-order fuctios map, foldr, foldl

More information

The Open University, Walton Hall, Milton Keynes, MK7 6AA First published 2004

The Open University, Walton Hall, Milton Keynes, MK7 6AA First published 2004 8 Programs ad data This publicatio forms part of a Ope Uiversity course M150 Data, Computig ad Iformatio. Details of this ad other Ope Uiversity courses ca be obtaied from the Course Iformatio ad Advice

More information

How do we evaluate algorithms?

How do we evaluate algorithms? F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:

More information

One advantage that SONAR has over any other music-sequencing product I ve worked

One advantage that SONAR has over any other music-sequencing product I ve worked *gajedra* D:/Thomso_Learig_Projects/Garrigus_163132/z_productio/z_3B2_3D_files/Garrigus_163132_ch17.3d, 14/11/08/16:26:39, 16:26, page: 647 17 CAL 101 Oe advatage that SONAR has over ay other music-sequecig

More information

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation 6-0-0 Kowledge Trasformatio from Task Scearios to View-based Desig Diagrams Nima Dezhkam Kamra Sartipi {dezhka, sartipi}@mcmaster.ca Departmet of Computig ad Software McMaster Uiversity CANADA SEKE 08

More information

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions Proceedigs of the 10th WSEAS Iteratioal Coferece o APPLIED MATHEMATICS, Dallas, Texas, USA, November 1-3, 2006 316 A Geeralized Set Theoretic Approach for Time ad Space Complexity Aalysis of Algorithms

More information

CSCI 123 Introduction to Programming Concepts in C++

CSCI 123 Introduction to Programming Concepts in C++ CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe Function Pass By Reference What s wrong? for(int star = 0; star < 10; star++) { } for(star = 0; star < 10; star++) { } Style Open and End

More information

Package RcppRoll. December 22, 2014

Package RcppRoll. December 22, 2014 Type Package Package RcppRoll December 22, 2014 Title Fast rollig fuctios through Rcpp ad RcppArmadillo Versio 0.1.0 Date 2013-01-10 Author Kevi Ushey Maitaier Kevi Ushey RcppRoll

More information

Lecture 6. Lecturer: Ronitt Rubinfeld Scribes: Chen Ziv, Eliav Buchnik, Ophir Arie, Jonathan Gradstein

Lecture 6. Lecturer: Ronitt Rubinfeld Scribes: Chen Ziv, Eliav Buchnik, Ophir Arie, Jonathan Gradstein 068.670 Subliear Time Algorithms November, 0 Lecture 6 Lecturer: Roitt Rubifeld Scribes: Che Ziv, Eliav Buchik, Ophir Arie, Joatha Gradstei Lesso overview. Usig the oracle reductio framework for approximatig

More information

FURTHER INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS)

FURTHER INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS) Mathematics Revisio Guides More Trigoometric ad Log Itegrals Page of 7 MK HOME TUITION Mathematics Revisio Guides Level: AS / A Level AQA : C Edexcel: C OCR: C OCR MEI: C FURTHER INTEGRATION TECHNIQUES

More information