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

Size: px
Start display at page:

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

Transcription

1 Priciples of programmig laguages From last week Lecture 5 Natalia Silvis-Cividjia silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for logical ad? If both operads are boolea, the & ca be used as && but without short-circuitig ML: Value of a i halve? vrije Uiversiteit amsterdam Outlie Part I. Polymorphism Part II. Fuctioal programmig. Third look at ML. 1

2 What is polymorphism? Polymorphism poly+morphos (Greek) = may forms (shapes) Used i may other scieces: material sciece, biology I programmig laguages PMF is difficult to defie: Applies to a wide variety of laguage features Most laguages have at least a little First we examie a few major examples, the we try to give a defiitio that covers them Polymorfism examples Overloadig Parameter coercio Parametric polymorphism Defiitios ad classificatios What is overloadig? Overloadig = to give more tha oe defiitio, all of differet types You ca overload: operators or fuctio ames Predefied Overloaded Operators Some operators are already overloaded by the laguage itself. ML: val x = 1 + 2; val y = ; C++: a = 1 + 2; b = ; c = "hello " + "there"; How does the laguages system kow which defiitio to use? 2

3 User-Overloaded Operators Situatios: You ca add two itegers or two floats, but what if you wat to add two complex umbers? You ca compare two itegers, two strigs, but how to compare 2 C structures? Ex: Overloadig the < operator i C++ #iclude <iostream> #iclude <strig> usig amespace std ; struct Studet { strig ame ; it stud_r ; it grade ; ; // overloads < operator to compare 2 structs of type Studet bool operator< (cost Studet& studet1, cost Studet& studet2) { if (studet1.grade < studet2.grade) retur true ; else retur false ; Ex: Overloadig the < operator i C++ (ctd) it mai() { Studet me, you ; me.ame = "Sheila" ; me.stud_r = ; me.grade = 8 ; you.ame = "Bob" ; you.stud_r = ; you.grade = 4 ; if (me < you) cout << you.ame << " is more clever tha " << me.ame ; else cout << me.ame << " is more clever tha " << you.ame ; cout << edl ; retur 0 ; Output: Sheila is more cleaver tha Bob C++ Operator overloadig rules All operators ca be overloaded except:. (direct member), :: (scope resolutio),.* ad?: You caot chage the uary/biary ature of a operator. You caot override precedece rules. Take care! Overloadig ca become cofusig. The user has to use his commo sese ad ot overdo it. Overloaded Fuctio Names I some laguages (Java, C++), the user ca overload the fuctio ame = same ame, differet defiitio (differet sematics) it square(it x) { retur x*x; double square(double x) { retur x*x; The bodies look the same, but the implemetatio by hardware is very differet. Implemetig Overloadig Compilers implemet overloadig (solve the ambiguity) like this: Create a set of moomorphic fuctios, oe for each defiitio Ivet a magled ame for each, ecodig the type iformatio Ex: fred_fii Have each referece use the appropriate magled ame, depedig o the parameter types 3

4 Mai feature of overloadig Polymorphism examples The laguage system looks at the operators type ad decides which defiitio to use. Overloadig Parameter coercio Parametric polymorphism Defiitios ad classificatios Coercio Defiig Coercios A coercio is a implicit type coversio, supplied automatically Explicit type coversio i Java: Implicit coversio (Coercio) i Java: OR double x; x = (double) 2; double x; x = 2; This coercio is ot polymorphism, x is ot polymorphic Laguage defiitios ofte take may pages to defie exactly which coercios are performed Some laguages, especially some older laguages like Algol 68 ad PL/I, have very extesive powers of coercio Some, like ML, have oe Most, like Java, are somewhere i the middle Defiig coercio i Java Uary Numeric Promotio Some operators apply uary umeric promotio to a sigle operad, which must produce a value of a umeric type: If the operad is of compile-time type byte, short, or char, uary umeric promotio promotes it to a value of type it by a wideig coversio ( 5.1.2). Otherwise, a uary umeric operad remais as is ad is ot coverted. Uary umeric promotio is performed o expressios i the followig situatios: the dimesio expressio i array creatios ( 15.9); the idex expressio i array access expressios ( 15.12); operads of the uary operators plus + ( ) ad mius - ( )... Parameter Coercio if a laguage supports coercio of parameters o a fuctio call (or of operads whe a operator is applied), the resultig fuctio (or operator) is polymorphic The Java Laguage Specificatio James Goslig, Bill Joy, Guy Steele 4

5 Example: Java void f(double x) { f((byte) 1); f((short) 2); f('a'); f(3); f(4l); f(5.6f); This f ca be called with ay type of parameter Java is willig to coerce to type double f is polymorphic Coercio vs. Overloadig There are potetially tricky iteractios betwee overloadig ad coercio Overloadig uses the types to choose the defiitio Coercio uses the defiitio to choose a type coversio Ambiguities might appear ad each laguage system has to solve them i some way. Ambiguity Example Ambiguity Example Suppose that, like C++, a laguage is willig to coerce char to it or to double it square(it x) { retur x*x; double square(double x) { retur x*x; Which square gets called for square('a')? Suppose that, like C++, a laguage is willig to coerce char to it Which f gets called for f('a', 'b')? void f(it x, char y) { void f(char x, it y) { Outlie Parametric Polymorphism Overloadig Parameter coercio Parametric polymorphism Defiitios ad classificatios A fuctio exhibits parametric polymorphism if it has a type that cotais oe or more type variables - fu f(a, b) = (a = b); val f = f : ''a * ''a -> bool A type with type variables is a polytype Foud i ML, C++ ad Ada, Java 5

6 Ex: C++ Fuctio templates // returs the maximum of 2 itegers it max (it left, it right) { if (left < right) retur right ; else retur left ; What is the problem here? What do we eed to solve it? //returs the maximum of 2 doubles double max (double left, double right) { if (left < right) retur right ; else retur left ; Ex: C++ Fuctio templates A fuctio template for the fuctio max: template <class T> T max (T left, T right) { if (left < right) retur right ; else retur left ; Here class T meas type T. T is a type variable T ca be ay type for which the operator < is defied For other types, operator < ca be overloaded. Ex: C++ Fuctio templates #iclude <iostream> usig amespace std;.. place here the fuctio template it mai() { it iteger1 = 4 ; it iteger2 = 10 ; it max1 = max (iteger1, iteger2); cout << "The maximum iteger is " << max1 << edl ; double double1 = ; double double2 = 5.7 ; double max2 = max (double1,double2) ; cout << "The maximum double is " << max2 << edl ; retur 0 ; Implemetatio May copies vs. oe copy A improved implemetatio for parametric polymorphism is a active are of programmig laguage research Outlie Overloadig Parameter coercio Parametric polymorphism Defiitios ad classificatios So what is polymorphism? 6

7 A attempt at a defiitio A fuctio or operator is polymorphic if it has at least two possible types. How may types? ad hoc polymorphism if it has oly fiitely may possible types uiversal polymorphism if it has ifiitely may possible types Ad hoc/uiversal? Summary Overloadig Parametric coercio Parametric polymorphism Ad hoc Ad hoc Uiversal Coclusio There are may more pheomea that people call polymorphism. We preseted oly 3 examples ad gave a defiitio that covers them. Laguages with dyamic type checkig do ot eed polymorphism. Polymorphism is a way to gai some freedom ad flexibility ad still beefit from the static type checkig Polymorphism is powerful ad flexible feature but it presets opportuities for abuse. Exercises 1.(Weber Ch.8 ex.1) try yourself at home 2.(Weber Ch.8 ex.3) (i class) Cosider a ukow laguage with iteger ad real types i which 1+2, 1.0+2, ad are all legal expressios. a. Explai how this could be the result of coercio, usig o overloadig b. Explai how this could be the result of overloadig usig o coercio c. Explai how this could result from a combiatio of overloadig ad coercio 7

8 Outlie Outlie Part II. Fuctioal programmig. A third look at ML More patter matchig Fuctio values ad aoymous fuctios Higher-order fuctios ad curryig Some ML predefied higher-order fuctios More Patter-Matchig Match Sytax Last time we saw patter-matchig i fuctio defiitios: A rule: <rule> ::= <patter> => <expressio> fu f 0 = "zero" f _ = "o-zero"; A match cosists of oe or more rules separated by a vertical bar, like this: <match> ::= <rule> <rule> ' ' <match> Case Expressios Example - case 1+1 of = 3 => "three" = 2 => "two" = _ => "hmm"; val it = "two" : strig case x of _::_::c::_ => c _::b::_ => b a::_ => a il => 0 8

9 Geeralizes if if exp 1 the exp 2 else exp 3 case exp 1 of true => exp 2 false => exp 3 Behid the Scees Expressios usig if are actually treated as abbreviatios for case expressios This explais some odd SML/NJ error messages: The two expressios above are equivalet So if-the-else is really just a special case of case - if 1=1 the 1 else 1.0; Error: types of rules do't agree [literal] earlier rule(s): bool -> it this rule: bool -> real i rule: false => 1.0 Outlie Predefied Fuctios More patter matchig Fuctio values ad aoymous fuctios Higher-order fuctios ad curryig Predefied higher-order fuctios Whe a ML laguage system starts, there are may predefied variables Some are boud to fuctios: - ord; val it = f : char -> it - ~; val it = f : it -> it Defiig Fuctios Fuctio Values We have see the fu otatio for defiig ew amed fuctios You ca also defie ew ames for old fuctios, usig val just as for other kids of values: - val x = ~; val x = f : it -> it - x 3; val it = ~3 : it Fuctios i ML do ot have ames Just like other kids of values, fuctio values may be give oe or more ames by bidig them to variables The fu sytax does two separate thigs: Creates a ew fuctio value Bids that fuctio value to a ame 9

10 Aoymous Fuctios Named fuctio: fu - fu f x = x + 2; val f = f : it -> it - f 1; val it = 3 : it Aoymous fuctio: f - f x => x + 2; val it = f : it -> it - (f x => x + 2) 1; val it = 3 : it Usig Aoymous Fuctios whe you eed a small fuctio i just oe place ad you wat to avoid clutterig With amed fuctio - fu itbefore (a,b) = a < b; val itbefore = f : it * it -> bool - quicksort ([1,4,3,2,5], itbefore); val it = [1,2,3,4,5] : it list With aoymous fuctio: - quicksort ([1,4,3,2,5], f (a,b) => a<b); val it = [1,2,3,4,5] : it list - quicksort ([1,4,3,2,5], f (a,b) => a>b); val it = [5,4,3,2,1] : it list The op keyword - op *; val it = f : it * it -> it - quicksort ([1,4,3,2,5], op <); val it = [1,2,3,4,5] : it list Biary operators are special fuctios The keyword op before a operator extracts the fuctio used by the operator Outlie Higher-order Fuctios More patter matchig Fuctio values ad aoymous fuctios Higher-order fuctios ad curryig Predefied higher-order fuctios Every fuctio has a order: A fuctio that does ot take ay fuctios as parameters, ad does ot retur a fuctio value, has order 1 A fuctio that takes a fuctio as a parameter or returs a fuctio value has order +1, where is the order of its highest-order parameter or retured value The quicksort we just saw is a secodorder fuctio 10

11 Practice What is the order of fuctios with each of the followig ML types? it * it -> bool it list * (it * it -> bool) -> it list it -> it -> it (it -> it) * (it -> it) -> (it -> it) it -> bool -> real -> strig Curryig I ML fuctios have oly oe parameter. Q: How to pass 2 parameters to a fuctio? A1: By passig a 2-tuple: fu f (a,b) = a + b; A2: By curryig = write a fuctio that takes the first argumet, ad returs aother fuctio that takes the secod argumet ad returs the fial result: fu g a = f b => a+b; Haskell B. Curry, ( ) FP mathematicia Example - fu f (a,b) = a+b; val f = f : it * it -> it - fu g a = f b => a+b; val g = f : it -> it -> it - f(2,3); val it = 5 : it - g 2 3; val it = 5 : it Remember that fuctio applicatio is leftassociative So g 2 3 meas ((g 2) 3) 11

12 Advatages No tuples: we write g 2 3 istead of f(2,3) But the real advatage: we get to specialize fuctios for particular iitial parameters - val add2 = g 2; val add2 = f : it -> it - add2 3; val it = 5 : it - add2 10; val it = 12 : it Advatages - quicksort (op <) [1,4,3,2,5]; val it = [1,2,3,4,5] : it list - val sortbackward = quicksort (op >); val sortbackward = f : it list -> it list - sortbackward [1,4,3,2,5]; val it = [5,4,3,2,1] : it list Multiple Curried Parameters Curryig geeralizes to ay umber of parameters - fu f (a,b,c) = a+b+c; val f = f : it * it * it -> it - fu g a = f b => f c => a+b+c; val g = f : it -> it -> it -> it - f (1,2,3); val it = 6 : it - g 1 2 3; val it = 6 : it Easier Notatio for Curryig Istead of writig: fu f a = f b => a+b; We ca just write: fu f a b = a+b; This geeralizes for ay umber of curried argumets - fu f a b c d = a+b+c+d; val f = f : it -> it -> it -> it -> it Outlie ML Predefied Higher-Order Fuctios More patter matchig map Fuctio values ad aoymous fuctios Higher-order fuctios ad curryig foldr foldl Predefied higher-order fuctios 12

13 The map Fuctio Used to apply a fuctio to every elemet of a list, ad collect a list of results - map ~ [1,2,3,4]; val it = [~1,~2,~3,~4] : it list - map (f x => x+1) [1,2,3,4]; val it = [2,3,4,5] : it list - map (f x => x mod 2 = 0) [1,2,3,4]; val it = [false,true,false,true] : bool list - map (op +) [(1,2),(3,4),(5,6)]; val it = [3,7,11] : it list What is the type of map? The map Fuctio Is Curried The foldr Fuctio - map; val it = f : ('a -> 'b) -> 'a list -> 'b list - val f = map (op +); val f = f : (it * it) list -> it list - f [(1,2),(3,4)]; val it = [3,7] : it list Use map fuctio whe the result is a list of the same legth with the parameter Used to combie all the elemets of a list (starts from right to left) For example, to add up all the elemets of a list x, we could write foldr (op +) 0 x It takes a fuctio f, a startig value c, ad a list x = [x 1,, x ] ad computes: f x f x, f x, f x c ( ( ( ( )) )) 1, 2 1, So foldr (op +) 0 [1,2,3,4] evaluates as 1+(2+(3+(4+0)))=10 Foldr: examples Fuctio start_value list - foldr (op +) 0 [1,2,3,4]; val it = 10 : it - foldr (op * ) 1 [1,2,3,4]; val it = 24 : it - foldr (op ^) "" ["abc","def","ghi"]; val it = "abcdefghi" : strig - foldr (op ::) [5] [1,2,3,4]; val it = [1,2,3,4,5] : it list The foldr Fuctio Is Curried - foldr; val it = f : ('a * 'b -> 'b) -> 'b -> 'a list -> 'b - foldr (op +); val it = f : it -> it list -> it - foldr (op +) 0; val it = f : it list -> it - val addup = foldr (op +) 0; val addup = f : it list -> it - addup [1,2,3,4,5]; val it = 15 : it 13

14 The foldl Fuctio The foldl Fuctio Used to combie all the elemets of a list Same results as foldr i some cases - foldl (op +) 0 [1,2,3,4]; val it = 10 : it - foldl (op * ) 1 [1,2,3,4]; val it = 24 : it To add up all the elemets of a list x, we could write foldl (op +) 0 x It takes a fuctio f, a startig value c, ad a list x = [x 1,, x ] ad computes: f x f x, f x, f x c ( ( ( ( )) )), 1 2 1, So foldl (op +) 0 [1,2,3,4] evaluates as 4+(3+(2+(1+0)))=10 Remember, foldr did 1+(2+(3+(4+0)))=10 The foldl Fuctio foldl starts at the left, foldr starts at the right Differece does ot matter whe the fuctio is associative ad commutative, like + ad * For other operatios, it does matter - foldr (op ^) "" ["abc","def","ghi"]; val it = "abcdefghi" : strig - foldl (op ^) "" ["abc","def","ghi"]; val it = "ghidefabc" : strig - foldr (op -) 0 [1,2,3,4]; val it = ~2 : it - foldl (op -) 0 [1,2,3,4]; val it = 2 : it Exercises (Weber, Ch. 9) Exercise 3. Write a fuctio squarelist of type it list -> it list that takes a list of itegers ad returs the list of squares of those itegers. Exercise 17. Write a fuctio max of type it list ->it that returs the largest elemet of a list. Your fuctio does ot eed to behave well if the list is empty. 14

A Third Look At ML. Chapter Nine Modern Programming Languages, 2nd ed. 1

A Third Look At ML. Chapter Nine Modern Programming Languages, 2nd ed. 1 A Third Look At ML Chapter Nine Modern Programming Languages, 2nd ed. 1 Outline More pattern matching Function values and anonymous functions Higher-order functions and currying Predefined higher-order

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

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

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

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

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 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 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

implement language system

implement language system Outlie Priciples of programmig laguages Lecture 3 http://few.vu.l/~silvis/ppl/2007 Part I. Laguage systems Part II. Fuctioal programmig. First look at ML. Natalia Silvis-Cividjia e-mail: silvis@few.vu.l

More information

n Haskell n Syntax n Lazy evaluation n Static typing and type inference n Algebraic data types n Pattern matching n Type classes

n Haskell n Syntax n Lazy evaluation n Static typing and type inference n Algebraic data types n Pattern matching n Type classes Aoucemets Quiz 7 HW 9 is due o Friday Raibow grades HW 1-6 plus 8. Please, read our commets o 8! Exam 1-2 Quiz 1-6 Ay questios/cocers, let us kow ASAP Last Class Haskell Sytax Lazy evaluatio Static typig

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

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

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

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

. 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

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

Last Class. Announcements. Lecture Outline. Types. Structural Equivalence. Type Equivalence. Read: Scott, Chapters 7 and 8. T2 y; x = y; n Types

Last Class. Announcements. Lecture Outline. Types. Structural Equivalence. Type Equivalence. Read: Scott, Chapters 7 and 8. T2 y; x = y; n Types Aoucemets HW9 due today HW10 comig up, will post after class Team assigmet Data abstractio (types) ad cotrol abstractio (parameter passig) Due o Tuesday, November 27 th Last Class Types Type systems Type

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

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

int f(char a, char b) {

int f(char a, char b) { Polymorphism Chapter Eight Modern Programming Languages 1 Introduction Compare these function types The ML function is more flexible, since it can be applied to any pair of the same (equality-testable)

More information

Polymorphism. Chapter Eight Modern Programming Languages, 2nd ed. 1

Polymorphism. Chapter Eight Modern Programming Languages, 2nd ed. 1 Polymorphism Chapter Eight Modern Programming Languages, 2nd ed. 1 Introduction Compare these function types The ML function is more flexible, since it can be applied to any pair of the same (equality-testable)

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

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

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

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

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig

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

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

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

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

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

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

Lecture 9: Exam I Review

Lecture 9: Exam I Review CS 111 (Law): Program Desig I Lecture 9: Exam I Review Robert H. Sloa & Richard Warer Uiversity of Illiois, Chicago September 22, 2016 This Class Discuss midterm topics Go over practice examples Aswer

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

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

top() Applications of Stacks

top() Applications of Stacks CS22 Algorithms ad Data Structures MW :00 am - 2: pm, MSEC 0 Istructor: Xiao Qi Lecture 6: Stacks ad Queues Aoucemets Quiz results Homework 2 is available Due o September 29 th, 2004 www.cs.mt.edu~xqicoursescs22

More information

CS211 Fall 2003 Prelim 2 Solutions and Grading Guide

CS211 Fall 2003 Prelim 2 Solutions and Grading Guide CS11 Fall 003 Prelim Solutios ad Gradig Guide Problem 1: (a) obj = obj1; ILLEGAL because type of referece must always be a supertype of type of object (b) obj3 = obj1; ILLEGAL because type of referece

More information

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015. Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Hash Tables xkcd. http://xkcd.com/221/. Radom Number. Used with permissio uder Creative

More information

Lecture 1. Topics. Principles of programming languages (2007) Lecture 1. What makes programming languages such an interesting subject?

Lecture 1. Topics. Principles of programming languages (2007) Lecture 1. What makes programming languages such an interesting subject? Priciples of programmig laguages (2007) Lecture 1 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l Lecture 1. Topics Studet survey Itroductio History of major programmig

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

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

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

BOOLEAN MATHEMATICS: GENERAL THEORY

BOOLEAN MATHEMATICS: GENERAL THEORY CHAPTER 3 BOOLEAN MATHEMATICS: GENERAL THEORY 3.1 ISOMORPHIC PROPERTIES The ame Boolea Arithmetic was chose because it was discovered that literal Boolea Algebra could have a isomorphic umerical aspect.

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

Module 8-7: Pascal s Triangle and the Binomial Theorem

Module 8-7: Pascal s Triangle and the Binomial Theorem Module 8-7: Pascal s Triagle ad the Biomial Theorem Gregory V. Bard April 5, 017 A Note about Notatio Just to recall, all of the followig mea the same thig: ( 7 7C 4 C4 7 7C4 5 4 ad they are (all proouced

More information

n Haskell n Covered syntax, lazy evaluation, static typing n Algebraic data types and pattern matching n Type classes n Monads and more n Types

n Haskell n Covered syntax, lazy evaluation, static typing n Algebraic data types and pattern matching n Type classes n Monads and more n Types Aoucemets Exam 2 is graded, but I will eed some time to go over it I ll release grades this eveig (figers crossed!) Raibow grades: HW1-6, Exam 1-2, Quiz 1-5 Will post aswer key Still gradig: Quiz 6, HW7

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions: CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed

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

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

BaanERP Tools. Programming features

BaanERP Tools. Programming features BaaERP Tools A publicatio of: Baa Developmet B.V. P.O.Box 143 3770 AC Bareveld The Netherlads Prited i the Netherlads Baa Developmet B.V. 1998. All rights reserved. The iformatio i this documet is subject

More information

ECE4050 Data Structures and Algorithms. Lecture 6: Searching

ECE4050 Data Structures and Algorithms. Lecture 6: Searching ECE4050 Data Structures ad Algorithms Lecture 6: Searchig 1 Search Give: Distict keys k 1, k 2,, k ad collectio L of records of the form (k 1, I 1 ), (k 2, I 2 ),, (k, I ) where I j is the iformatio associated

More information

Java Expressions & Flow Control

Java Expressions & Flow Control Java Expressios & Flow Cotrol Rui Moreira Expressio Separators:. [ ] ( ), ; Dot used as decimal separator or to access attributes ad methods double d = 2.6; Poto poto = ew Poto(2, 3); it i = poto.x; it

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

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

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs CHAPTER IV: GRAPH THEORY Sectio : Itroductio to Graphs Sice this class is called Number-Theoretic ad Discrete Structures, it would be a crime to oly focus o umber theory regardless how woderful those topics

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

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

Designing a learning system

Designing a learning system CS 75 Machie Learig Lecture Desigig a learig system Milos Hauskrecht milos@cs.pitt.edu 539 Seott Square, x-5 people.cs.pitt.edu/~milos/courses/cs75/ Admiistrivia No homework assigmet this week Please try

More information

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1 CS200: Hash Tables Prichard Ch. 13.2 CS200 - Hash Tables 1 Table Implemetatios: average cases Search Add Remove Sorted array-based Usorted array-based Balaced Search Trees O(log ) O() O() O() O(1) O()

More information

Appendix D. Controller Implementation

Appendix D. Controller Implementation COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Appedix D Cotroller Implemetatio Cotroller Implemetatios Combiatioal logic (sigle-cycle); Fiite state machie (multi-cycle, pipelied);

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

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

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

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

Designing a learning system

Designing a learning system CS 75 Itro to Machie Learig Lecture Desigig a learig system Milos Hauskrecht milos@pitt.edu 539 Seott Square, -5 people.cs.pitt.edu/~milos/courses/cs75/ Admiistrivia No homework assigmet this week Please

More information

Project 2.5 Improved Euler Implementation

Project 2.5 Improved Euler Implementation Project 2.5 Improved Euler Implemetatio Figure 2.5.10 i the text lists TI-85 ad BASIC programs implemetig the improved Euler method to approximate the solutio of the iitial value problem dy dx = x+ y,

More information

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013 Code Review s Authors: Mika V. Mätylä ad Casper Lasseius Origial versio: 4 Sep, 2007 Made available olie: 24 April, 2013 This documet cotais further details of the code review defects preseted i [1]. of

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

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations Chapter 14 Graph class desig Bjare Stroustrup Abstract We have discussed classes i previous lectures Here, we discuss desig of classes Library desig cosideratios Class hierarchies (object-orieted programmig)

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

Solutions to Final COMS W4115 Programming Languages and Translators Monday, May 4, :10-5:25pm, 309 Havemeyer

Solutions to Final COMS W4115 Programming Languages and Translators Monday, May 4, :10-5:25pm, 309 Havemeyer Departmet of Computer ciece Columbia Uiversity olutios to Fial COM W45 Programmig Laguages ad Traslators Moday, May 4, 2009 4:0-5:25pm, 309 Havemeyer Closed book, o aids. Do questios 5. Each questio is

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

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5 Morga Kaufma Publishers 26 February, 28 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Set-Associative Cache Architecture Performace Summary Whe CPU performace icreases:

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

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output File class i Java File Iput ad Output TOPICS File Iput Exceptio Hadlig File Output Programmers refer to iput/output as "I/O". The File class represets files as objects. The class is defied i the java.io

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

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes Prelimiaries Liked Lists public class StrageObject { Strig ame; StrageObject other; Arrays are ot always the optimal data structure: A array has fixed size eeds to be copied to expad its capacity Addig

More information

5.3 Recursive definitions and structural induction

5.3 Recursive definitions and structural induction /8/05 5.3 Recursive defiitios ad structural iductio CSE03 Discrete Computatioal Structures Lecture 6 A recursively defied picture Recursive defiitios e sequece of powers of is give by a = for =0,,, Ca

More information

CS 111: Program Design I Lecture 15: Modules, Pandas again. Robert H. Sloan & Richard Warner University of Illinois at Chicago March 8, 2018

CS 111: Program Design I Lecture 15: Modules, Pandas again. Robert H. Sloan & Richard Warner University of Illinois at Chicago March 8, 2018 CS 111: Program Desig I Lecture 15: Modules, Padas agai Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago March 8, 2018 PYTHON STANDARD LIBRARY & BEYOND: MODULES Extedig Pytho Every moder

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

A graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n))

A graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n)) ca see that time required to search/sort grows with size of We How do space/time eeds of program grow with iput size? iput. time: cout umber of operatios as fuctio of iput Executio size operatio Assigmet:

More information

CS 111: Program Design I Lecture 21: Network Analysis. Robert H. Sloan & Richard Warner University of Illinois at Chicago April 10, 2018

CS 111: Program Design I Lecture 21: Network Analysis. Robert H. Sloan & Richard Warner University of Illinois at Chicago April 10, 2018 CS 111: Program Desig I Lecture 21: Network Aalysis Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago April 10, 2018 NETWORK ANALYSIS Which displays a graph i the sese of graph/etwork aalysis?

More information

CMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago

CMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago CMSC 22200 Computer Architecture Lecture 3: ISA ad Itroductio to Microarchitecture Prof. Yajig Li Uiversity of Chicago Lecture Outlie ISA uarch (hardware implemetatio of a ISA) Logic desig basics Sigle-cycle

More information

condition w i B i S maximum u i

condition w i B i S maximum u i ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility

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

CS 111: Program Design I Lecture 15: Objects, Pandas, Modules. Robert H. Sloan & Richard Warner University of Illinois at Chicago October 13, 2016

CS 111: Program Design I Lecture 15: Objects, Pandas, Modules. Robert H. Sloan & Richard Warner University of Illinois at Chicago October 13, 2016 CS 111: Program Desig I Lecture 15: Objects, Padas, Modules Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago October 13, 2016 OBJECTS AND DOT NOTATION Objects (Implicit i Chapter 2, Variables,

More information

Arithmetic Sequences

Arithmetic Sequences . Arithmetic Sequeces COMMON CORE Learig Stadards HSF-IF.A. HSF-BF.A.1a HSF-BF.A. HSF-LE.A. Essetial Questio How ca you use a arithmetic sequece to describe a patter? A arithmetic sequece is a ordered

More information

Announcements TREES II. Comparing Data Structures. Binary Search Trees. Red-Black Trees. Red-Black Trees 3/13/18

Announcements TREES II. Comparing Data Structures. Binary Search Trees. Red-Black Trees. Red-Black Trees 3/13/18 //8 Aoucemets Prelim is Toight, brig your studet ID :PM EXAM OLH: etids startig aa to dh OLH: etids startig di to ji PHL: etids startig jj to ks (Plus studets who switched from the 7: exam) TREES II Lecture

More information

Location Steps and Paths

Location Steps and Paths Locatio Steps ad Paths 3 INTHIS CHAPTER Uderstadig Locatio Steps ad Paths How do locatio paths work? We took a look at locatio paths i the overview i Chapter 1, where we saw that locatio paths look much

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

On Infinite Groups that are Isomorphic to its Proper Infinite Subgroup. Jaymar Talledo Balihon. Abstract

On Infinite Groups that are Isomorphic to its Proper Infinite Subgroup. Jaymar Talledo Balihon. Abstract O Ifiite Groups that are Isomorphic to its Proper Ifiite Subgroup Jaymar Talledo Baliho Abstract Two groups are isomorphic if there exists a isomorphism betwee them Lagrage Theorem states that the order

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

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

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

Data diverse software fault tolerance techniques

Data diverse software fault tolerance techniques Data diverse software fault tolerace techiques Complemets desig diversity by compesatig for desig diversity s s limitatios Ivolves obtaiig a related set of poits i the program data space, executig the

More information

Data Structures Week #5. Trees (Ağaçlar)

Data Structures Week #5. Trees (Ağaçlar) Data Structures Week #5 Trees Ağaçlar) Trees Ağaçlar) Toros Gökarı Avrupa Gökarı October 28, 2014 Boraha Tümer, Ph.D. 2 Trees Ağaçlar) October 28, 2014 Boraha Tümer, Ph.D. 3 Outlie Trees Deiitios Implemetatio

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

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

CSE 417: Algorithms and Computational Complexity

CSE 417: Algorithms and Computational Complexity Time CSE 47: Algorithms ad Computatioal Readig assigmet Read Chapter of The ALGORITHM Desig Maual Aalysis & Sortig Autum 00 Paul Beame aalysis Problem size Worst-case complexity: max # steps algorithm

More information