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

Size: px
Start display at page:

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

Transcription

1 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 ad HW8 We will grade HW8 over weeked to use i HW9 Today s Lecture Outlie Haskell Covered sytax, lazy evaluatio, static typig Algebraic data types ad patter matchig Type classes Moads ad more Types Type systems Type checkig Type equivalece Fall 18 CSCI 4430, A Milaova 1 2 Algebraic Data Types Types Read: Scott, Chapter 7 Algebraic data types are tagged uios (aka sums) of products (aka records) data Shape = Lie Poit Poit Triagle Poit Poit Poit Quad Poit Poit Poit Poit uio Haskell keyword the ew type ew costructors (a.k.a. tags, disjucts, summads) Lie is a biary costructor, Triagle is a terary 3 Fall 18 CSCI 4430, A Milaova (example from MIT 2015 Program Aalysis OCW) 4 Algebraic Data Types i HW9 Patter Matchig Type sigature of achorpt: takes a Shape ad returs a Poit. Defiig a lambda expressio type Name = Strig data Expr = Var Name Lambda Name Expr App Expr Expr > e1 = Var x // Lambda term x > e2 = Lambda x e1 // Lambda term λx.x Fall 18 CSCI 4430, A Milaova 5 Examie values of a algebraic data type achorpt :: Shape -> Poit achorpt s = case s of Lie p1 p2 -> p1 Triagle p3 p4 p5 -> p3 Quad p6 p7 p8 p9 -> p6 Two poits Test: does the give value match this patter? Bidig: if value matches, bid correspodig values of s ad patter Fall 18 CSCI 4430, A Milaova (from MIT 2015 Program Aalysis OCW) 6 1

2 Patter Matchig Patter matchig decostructs a term > let h:t = aa i t a > let (x,y) = (10, aa ) i x 10 Fall 18 CSCI 4430, A Milaova 7 Patter Matchig i HW9 isfree::name -> Expr -> Bool isfree v e = case e of Var -> if ( == v) the True else False Lambda Type sigature of isfree. I Haskell, all fuctios are curried, i.e., they take just oe argumet. (-> is right-associative, Name -> Expr -> Bool is Name -> (Expr -> Bool).) isfree takes a variable ame, ad returs a fuctio that takes a expressio ad returs a boolea. Of course, we ca iterpret isfree as a fuctio that takes a variable ame ame ad a expressio Fall 18 CSCI 4430, A Milaova E, ad returs true if variable ame is free i E. 8 Geeric Fuctios i Haskell We ca geeralize a fuctio whe a fuctio makes o assumptios about the type: cost :: a -> b -> a cost x y = x apply :: (a->b)->a->b apply g x = g x Fall 18 CSCI 4430, A Milaova (examples from MIT 2015 Program Aalysis OCW) 9 Geeric Fuctios -- List datatype data List a = Nil Cos a (List a) Ca we write fuctio sum over a list of a s? sum :: a -> List a -> a sum Nil = sum (Cos x xs) = sum (+x) xs No. a o loger ucostrait. Type ad fuctio defiitio imply that we ca apply + o a but + is ot defied o all types! Type error: No istace for (Num a) arisig from a use of + 10 Haskell Type Classes Geeric Fuctios with Type Class Not to be cofused with Java classes/iterfaces Defie a type class cotaiig the arithmetic operators class Num a where (==) :: a -> a -> Bool (+) :: a -> a -> a istace Num It where x == y = istace Num Float where Fall 18 CSCI 4430, A Milaova Read: A type a is a istace of the type class Num if it provides overloaded defiitios of operatios ==, +, Read: It ad Float are istaces of Num 11 sum :: (Num a) => a -> List a -> a sum Nil = sum (Cos x xs) = sum (+x) xs Oe view of type classes: predicates (Num a) is a predicate i type defiitios Costrais the types we ca istatiate a geeric fuctio to specific types A type class has associated laws Fall 18 CSCI 4430, A Milaova 12 2

3 Type Class Hierarchy class Eq a where (==), (/=) :: a -> a -> Bool class (Eq a) => Ord where (<), (<=), (>), (>=) :: a -> a -> Bool mi, max :: a -> a -> a Each type class correspods to oe cocept Class costraits give rise to a hierarchy Eq is a superclass of Ord Ord iherits specificatio of (==) ad (/=) Notio of true subtypig Fall 18 CSCI 4430, A Milaova (modified from MIT 2015 Program Aalysis OCW) 13 Today s Lecture Outlie Haskell Algebraic data types ad patter matchig Type classes Moads ad more Types Type systems Type checkig Type equivalece 14 Moads Oe source: All About Moads (haskell.org) Aother source: Scott s book A way to clealy compose computatios E.g., f may retur a value of type a or Nothig Composig computatios becomes tedious: case (f s) of Nothig à Nothig Just m à case (f m) I Haskell, moads ecapsulate IO ad other imperative features Fall 18 CSCI 4430, A Milaova 15 A Example: Cloed Sheep type Sheep = father :: Sheep à Maybe Sheep father =... mother :: Sheep à Maybe Sheep mother = (Note: a cloed sheep may have both parets, or ot...) materalgradfather :: Sheep à Maybe Sheep materalgradfather s = case (mother s) of Nothig à Nothig Just m à father m Fall 18 CSCI 4430, A Milaova (Example from All About Moads Tutorial) 16 A Example The Moad Type Class motherspateralgradfather :: Sheep à Maybe Sheep motherspateralgradfather s = case (mother s) of Nothig à Nothig Just m à case (father m) of Nothig à Nothig Just gf à father gf Tedious, ureadable, difficult to maitai Moads help! Fall 18 CSCI 4430, A Milaova (Example from All About Moads Tutorial) 17 Haskell s Moad class requires 2 operatios, >>= (bid) ad retur class Moad m where // >>= (the bid operatio) takes a moad // m a, ad a fuctio that takes a ad turs // it ito a moad m b (>>=) :: m a à (a à m b) à m b // retur ecapsulates a value ito the moad retur :: a à m a 18 3

4 The Maybe Moad data Maybe a = Nothig Just a istace Moad Maybe where Nothig >>= f = Nothig (Just x) >>= f = f x retur = Just Cloed Sheep example: motherspateralgradfather s = (retur s) >>= mother >>= father >>= father (Note: if at ay poit, some fuctio returs Nothig, Nothig gets clealy propagated.) 19 The List Moad The List type is a moad! li >>= f = cocat (map f li) retur x = [x] Note: cocat::[[a]] à [a] e.g., cocat [[1,2],[3,4],[5,6]] yields [1,2,3,4,5,6] Use ay f s.t. f::aà[b]. f may yield a list of 0,1,2, elemets of type b, e.g., > f x = [x+1] > [1,2,3] >>= f --- yields? 20 The List Moad parets :: Sheep à [Sheep] parets s = MaybeToList (mother s) ++ MaybeToList (father s) gradparets :: Sheep à [Sheep] gradparets s = (parets s) >>= parets The do Notatio do otatio is sytactic sugar for moadic bid > f x = x+1 > g x = x*5 > [1,2,3] >>= (retur. f) >>= (retur. g) Or > [1,2,3] >>= \x->[x+1] >>= \y->[y*5] Or, make ecapsulated elemet explicit with do > do { x <- [1,2,3]; y <- (\x->[x+1]) x; (\y->[y*5]) y } Fall 18 CSCI 4430, A Milaova List Comprehesios List Comprehesios > [ x x <- [1,2,3,4] ] [1,2,3,4] > [ x x <- [1,2,3,4], x `mod` 2 == 0 ] [2,4] > [ [x,y] x <- [1,2,3], y <- [6,5,4] ] [[1,6],[1,5],[1,4],[2,6],[2,5],[2,4],[3,6],[3,5],[3,4]] --- Willy s all-pairs fuctio from test 23 List comprehesios are sytactic sugar o top of the do otatio! [ x x <- [1,2,3,4] ] is sytactic sugar for do { x <- [1,2,3,4]; retur x } [ [x,y] x <- [1,2,3], y <- [6,5,4] ] is sytactic sugar for do { x <- [1,2,3]; y<-[6,5,4]; retur [x,y] } Which i tur, we ca traslate ito moadic bid 24 4

5 So What is the Poit of the Moad Coveietly chais (builds) computatio Ecapsulates mutable state. E.g., IO: opefile :: FilePath -> IOMode -> IO Hadle hclose :: Hadle -> IO () -- void hiseof :: Hadle -> IO Bool hgetchar :: Hadle -> IO Char These operatios break referetially trasparecy. For example, hgetchar typically returs differet value whe called twice i a row! Fall 18 CSCI 4430, A Milaova 25 Today s Lecture Outlie Haskell Algebraic data types ad patter matchig Type classes Moads ad more Types Type systems Type checkig Type equivalece 26 What is a type? A set of values ad the valid operatios o those values Itegers: + - * / < <= = >= >... Arrays: lookup(<array>,<idex>) assig(<array>,<idex>,<value>) iitialize(<array>), setbouds(<array>) User-defied types: Java iterfaces What is the role of types? What is the role of types i programmig laguages? Sematic correctess Data abstractio Abstract Data Types Documetatio (static types oly) Fall 18 CSCI 4430, A Milaova/BG Ryder 27 Fall 18 CSCI 4430, A Milaova/BG Ryder 28 3 Views of Types Deotatioal (or set) poit of view: A type is simply a set of values. A value has a give type if it belogs to the set. E.g. it = {,0,1,2,... } char = { a, b,... } bool = { true, false } Abstractio-based poit of view: A type is a iterface cosistig of a set of operatios with well-defied meaig Fall 18 CSCI 4430, A Milaova/BG Ryder 29 3 Views of Types Costructive poit of view: Primitive/simple/built-i types: e.g., it, char, bool Composite/costructed types: Costructed by applyig type costructors poiter e.g., poiterto(it) array e.g., arrayof(char) or arrayof(char,20) or... record/struct e.g., record(age:it, ame:strig) uio e.g. uio(it, poiterto(char)) list e.g., list(...) fuctio e.g., float it CAN BE NESTED! poiterto(arrayof(poiterto(char))) For most of us, types are a mixture of these 3 views Fall 18 CSCI 4430, A Milaova/BG Ryder 30 5

6 What is a Type System? A mechaism to defie types ad associate them with programmig laguage costructs What is Type Checkig? The process of esurig that the program obeys the type rules of the laguage Additioal rules for type equivalece, type compatibility Importat from pragmatic poit of view Fall 18 CSCI 4430, A Milaova/BG Ryder 31 Type checkig ca be doe statically At compile-time, i.e., before executio Statically typed (or statically checked) laguage Type checkig ca be doe dyamically At rutime, i.e., durig executio Dyamically typed (or dyamically checked) laguage Fall 18 CSCI 4430, A Milaova/BG Ryder 32 What is Type Checkig? Statically typed (better term: statically checked) laguages Typically require type aotatios (e.g., A a, List<A> list) Typically have a complex type system, ad most of type checkig is performed statically (at compile-time) Ada, Pascal, Java, C++, Haskell, OCaml A form of early bidig Dyamically typed (better term: dyamically checked) laguages. Also kow as Duck typed Typically require o type aotatios! All type checkig is performed dyamically (at rutime) Smalltalk, Lisp ad Scheme, Pytho, JavaScript What is Type Checkig? The process of esurig that the program obeys the type rules of the laguage Textbook defies term prohibited applicatio (also kow as forbidde error): ituitively, a prohibited applicatio is a applicatio of a operatio o values of the wrog type is the property that o operatio ever applies to values of the wrog type at rutime. I.e., o prohibited applicatio (forbidde error) ever occurs Fall 18 CSCI 4430, A Milaova/BG Ryder 33 Fall 18 CSCI 4430, A Milaova/BG Ryder 34 Laguage Desig Choices Desig choice: what is the set of forbidde errors? Obviously, we caot forbid all possible sematic errors Defie a set of forbidde errors Desig choice: Oce we ve chose the set of forbidde errors, how does the type system prevet them? Static checks oly? Dyamic checks oly? A combiatio of both? Furthermore, are we goig to absolutely disallow forbidde errors (be type safe), or are we goig to allow for programs to circumvet the system ad exhibit forbidde errors (i.e., be type usafe)? Forbidde Errors Example: idexig a array out of bouds a[i], a is of size Boud, i<0 or Boud i I C, C++, this is ot a forbidde error 0 i ad i<boud is ot checked (bouds are ot part of type) What are the tradeoffs here? I Pascal, this is a forbidde error. Preveted with static checks 0 i ad i<boud must be checked at compile time What are the tradeoffs here? I Java, this is a forbidde error. It is preveted with dyamic checks 0 i ad i<boud must be checked at rutime What are the tradeoffs here? Fall 18 CSCI 4430, A Milaova 35 Fall 18 CSCI 4430, A Milaova/BG Ryder 36 6

7 Type Safety C++ is type usafe Java vs. C++: Java: Duck q; ; q.quack()class Duck has quack C++: Duck *q; ; q->quack()class Duck has quack Ca we ed up with a program that calls quack()o a object that is t a Duck? I Java? I C++? q->foo(66) is a prohibited applicatio (i.e., applicatio of a operatio o a value of the wrog type, i.e., forbidde error). Static type B* q promises the programmer that q will poit to a to be type usafe B object. However, laguage does ot hoor this promise 37 Fall 18 CSCI 4430, A Milaova/BG Ryder 38 Java is said to be type safe while C++ is said //#1 void* x = (void *) ew A; A B* q = (B*) x; //a safe dowcast? it case1 = q->foo(); //what happes? B //#2 void* x = (void *) ew A; B* q = (B *) x; //a safe dowcast? it case2 = q->foo(66); //what happes? virtual foo() virtual foo() vritual foo(it) What is Type Checkig What is Type Checkig? type safe type usafe statically ot statically typed typed (i.e., dyamically typed) Static typig vs. dyamic typig What are the advatages of static typig? What are the advatages of dyamic typig? Fall 18 CSCI 4430, A Milaova/BG Ryder 39 Fall 18 CSCI 4430, A Milaova/BG Ryder 40 Today s Lecture Outlie Haskell Algebraic data types ad patter matchig Type classes Moads ad more Types Type systems Type checkig Type Equivalece ad Type Compatibility Discussio ceters o o-object-orieted vo Neuma laguages that use the value model for variables: Fortra, C, Pascal Questios: e := expressio þ or ý Are e ad expressio of same type? a + b þ or ý Are a ad b of same type ad type supports +? foo(arg1, arg2,,argn) þ or ý Do the types of the argumets match the types of the formal parameters? Type equivalece

8 Type Equivalece Two ways of defiig type equivalece Structural equivalece: based o shape Roughly, two types are the same if they cosists of the same compoets, put together i the same way Name equivalece: based o lexical occurrece of the type defiitios Roughly, each type defiitio itroduces a ew type Strict ame equivalece Loose ame equivalece Fall 18 CSCI 4430, A Milaova/BG Ryder 43 Structural Equivalece A type ame is structurally equivalet to itself Two types are structurally equivalet if they are formed by applyig the same type costructor to structurally equivalet argumets After type declaratio type = T the type ame is structurally equivalet to T E.g., i Haskell, we saw type Name = Strig Declaratio makes a alias of T. ad T are said to be aliased types Fall 18 CSCI 4430, A Milaova/BG Ryder 44 Structural Equivalece Structural Equivalece Example, Pascal-like laguage: type S = array [0..99] of char type T = array [0..99] of char Example, C: typedef struct { it j, it k, it *ptr } cell; typedef struct { it, it m, it *p } elemet; Show by isomorphism of correspodig type trees Are these types equivalet? struct cell struct elemet { char data; { char c; it a[3]; it a[5]; struct cell *ext; struct elemet *ptr; } } Equivalet types: are field ames part of the struct costructed type? are array bouds part of the array costructed type? Fall 18 CSCI 4430, A Milaova/BG Ryder 45 Fall 18 CSCI 4430, A Milaova/BG Ryder 46 Name Equivalece Name equivalece Two types are ame equivalet if they correspod to the same type defiitio T: type array [1..20] of it; x,y: array [1..20] of it; w,z: T; v: T; x ad y are of same type, w, z,v are of same type, but x ad w are of differet types! A applicatio of a type costructor is a type defiitio. Red array is ONE TYPE DEFINITION. Blue array is ANOTHER TYPE DEFINITION. 47 Name Equivalece A subtlety arises with aliased types (e.g., type = T, typedef it Age i C) Strict ame equivalece A laguage i which aliased types are cosidered distict, is said to have strict ame equivalece (e.g., it ad Age above would be distict types) Loose ame equivalece A laguage i which aliased types are cosidered the same, is said to have loose ame equivalece (e.g., it ad Age would be same) 48 8

9 Name Equivalece type cell = // record/struct type type alik = poiter to cell type blik = alik p,q : poiter to cell r : alik s : blik t : poiter to cell u : alik Fall 18 CSCI 4430, A Milaova/BG Ryder 49 Fall 18 CSCI 4430, A Milaova/BG Ryder 50 9

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

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

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 n Try tutorial on front page to get started! n spring13/ n Stack Overflow!

n   n Try tutorial on front page to get started! n   spring13/ n Stack Overflow! Announcements n Rainbow grades: HW1-6, Quiz1-5, Exam1 n Still grading: HW7, Quiz6, Exam2 Intro to Haskell n HW8 due today n HW9, Haskell, out tonight, due Nov. 16 th n Individual assignment n Start early!

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

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

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

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

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

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

n Bottom-up (LR) parsing n Characteristic Finite State Machine (CFSM) n SLR(1) parsing table n Conflicts in SLR(1) n LR parsing variants

n Bottom-up (LR) parsing n Characteristic Finite State Machine (CFSM) n SLR(1) parsing table n Conflicts in SLR(1) n LR parsing variants Aoucemets Gradig HW1 Should be doe by the ed of today. Grades are set to release toight You have 1 week to issue re-grade request Raibow grades comig up over the weeked Last Class Bottom-up (LR) parsig

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

Goals of the Lecture UML Implementation Diagrams

Goals of the Lecture UML Implementation Diagrams Goals of the Lecture UML Implemetatio Diagrams Object-Orieted Aalysis ad Desig - Fall 1998 Preset UML Diagrams useful for implemetatio Provide examples Next Lecture Ð A variety of topics o mappig from

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

Example: Shifter. Cascaded Combinational Shifter. Bluespec-2: Types. Asynchronous pipeline with FIFOs (regs with interlocks)

Example: Shifter. Cascaded Combinational Shifter. Bluespec-2: Types. Asynchronous pipeline with FIFOs (regs with interlocks) Bluespec-2: Types Arvid Computer Sciece & Artificial Itelligece Lab Massachusetts Istitute of Techology Eample: Shifter Goal: implemet: y = shift (,s) where y is shifted by s positios. Suppose s is a 3-bit

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

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e)

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e) Appedix (RASD 3/e) MACIASZEK, L.A. (2007): Requiremets Aalysis ad System Desig, 3 rd ed. Addiso Wesley, Harlow Eglad ISBN 978-0-321-44036-5 Appedix Fudametals of Object Techology Pearso Educatio Limited

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

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

6.175: Constructive Computer Architecture. Oct 7,

6.175: Constructive Computer Architecture. Oct 7, 6.175: Costructive Computer Architecture Tutorial 2 Advaced BSV Qua Nguye (Now uses the correct dates o PPT slides) T02-1 Admiistrivia Today is add date! Please test vlsifarm machies Remaiig labs schedule

More information

Τεχνολογία Λογισμικού

Τεχνολογία Λογισμικού ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τεχνολογία Λογισμικού, 7ο/9ο εξάμηνο 2018-2019 Τεχνολογία Λογισμικού Ν.Παπασπύρου, Αν.Καθ. ΣΗΜΜΥ, ickie@softlab.tua,gr

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

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen COP4020 Programmig Laguages Names, Scopes, ad Bidigs Prof. Robert va Egele Overview Abstractios ad ames Bidig time Object lifetime Object storage maagemet Static allocatio Stack allocatio Heap allocatio

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

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

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

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

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

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

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

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

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

Minimum Spanning Trees

Minimum Spanning Trees Miimum Spaig Trees Miimum Spaig Trees Spaig subgraph Subgraph of a graph G cotaiig all the vertices of G Spaig tree Spaig subgraph that is itself a (free) tree Miimum spaig tree (MST) Spaig tree of a weighted

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

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

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

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

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

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

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 19 Query Optimizatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Query optimizatio Coducted by a query optimizer i a DBMS Goal:

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

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

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

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

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

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

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

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

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

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

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

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:

More information

Abstract Data Types (ADTs) Stacks. The Stack ADT ( 4.2) Stack Interface in Java

Abstract Data Types (ADTs) Stacks. The Stack ADT ( 4.2) Stack Interface in Java Abstract Data Types (ADTs) tacks A abstract data type (ADT) is a abstractio of a data structure A ADT specifies: Data stored Operatios o the data Error coditios associated with operatios Example: ADT modelig

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

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

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

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

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

Inductive Definition to Recursive Function

Inductive Definition to Recursive Function PDS: CS 11002 Computer Sc & Egg: IIT Kharagpur 1 Iductive Defiitio to Recursive Fuctio PDS: CS 11002 Computer Sc & Egg: IIT Kharagpur 2 Factorial Fuctio Cosider the followig recursive defiitio of the factorial

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

Goals of the Lecture Object Constraint Language

Goals of the Lecture Object Constraint Language Goals of the Lecture Object Costrait Laguage Object-Orieted Aalysis ad Desig - Fall 1998 Preset the Object Costrait Laguage Ð As best as possible, with the limited iformatio available from UML i a Nutshell

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

Generating Heap-bounded Programs in a Functional Setting

Generating Heap-bounded Programs in a Functional Setting Geeratig Heap-bouded Programs i a Fuctioal Settig Walid Taha, Stepha Eller, ad Hogwei Xi 2 Rice Uiversity, Housto, TX, USA {taha,besa}@cs.rice.edu 2 Bosto Uiversity, Bosto, MA, USA hwxi@cs.bu.edu Abstract.

More information

Counting the Number of Minimum Roman Dominating Functions of a Graph

Counting the Number of Minimum Roman Dominating Functions of a Graph Coutig the Number of Miimum Roma Domiatig Fuctios of a Graph SHI ZHENG ad KOH KHEE MENG, Natioal Uiversity of Sigapore We provide two algorithms coutig the umber of miimum Roma domiatig fuctios of a graph

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

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

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

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

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

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8)

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8) CIS 11 Data Structures ad Algorithms with Java Fall 017 Big-Oh Notatio Tuesday, September 5 (Make-up Friday, September 8) Learig Goals Review Big-Oh ad lear big/small omega/theta otatios Practice solvig

More information

What Is Object-Orientation?

What Is Object-Orientation? Iformatio Systems Cocepts What Is Object-Orietatio? Roma Kotchakov Birkbeck, Uiversity of Lodo Based o Chapter 4 of Beett, McRobb ad Farmer: Object Orieted Systems Aalysis ad Desig Usig UML, (4th Editio),

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

Examples and Applications of Binary Search

Examples and Applications of Binary Search Toy Gog ITEE Uiersity of Queeslad I the secod lecture last week we studied the biary search algorithm that soles the problem of determiig if a particular alue appears i a sorted list of iteger or ot. We

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

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

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

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

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

Lecture 5. Counting Sort / Radix Sort

Lecture 5. Counting Sort / Radix Sort Lecture 5. Coutig Sort / Radix Sort T. H. Corme, C. E. Leiserso ad R. L. Rivest Itroductio to Algorithms, 3rd Editio, MIT Press, 2009 Sugkyukwa Uiversity Hyuseug Choo choo@skku.edu Copyright 2000-2018

More information

Lecture 2: Spectra of Graphs

Lecture 2: Spectra of Graphs Spectral Graph Theory ad Applicatios WS 20/202 Lecture 2: Spectra of Graphs Lecturer: Thomas Sauerwald & He Su Our goal is to use the properties of the adjacecy/laplacia matrix of graphs to first uderstad

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

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

Abstract Syntax Trees. AST Data Structure. Visitor Interface. Accept methods. Visitor Methodology for AST Traversal CS412/CS413

Abstract Syntax Trees. AST Data Structure. Visitor Interface. Accept methods. Visitor Methodology for AST Traversal CS412/CS413 Abstract Syta Trees CS412/CS413 Itroductio to Copilers Ti Teitelbau Lecture 12: Visitors; Sybol Tables February 18, 2005 Separate AST costructio fro seatic checkig phase Traverse the AST ad perfor seatic

More information

Overview. Common tasks. Observation. Chapter 20 The STL (containers, iterators, and algorithms) 8/13/18. Bjarne Stroustrup

Overview. Common tasks. Observation. Chapter 20 The STL (containers, iterators, and algorithms) 8/13/18. Bjarne Stroustrup Overview Chapter 20 The STL (cotaiers, iterators, ad algorithms) Bjare Stroustrup www.stroustrup.com/programmig Commo tasks ad ideals Geeric programmig Cotaiers, algorithms, ad iterators The simplest algorithm:

More information

MetaML and multi-stage programming with explicit annotations

MetaML and multi-stage programming with explicit annotations Orego Health & Sciece Uiversity OHSU Digital Commos CSETech Jauary 1999 MetaML ad multi-stage programmig with explicit aotatios Walid Taha Tim Sheard Follow this ad additioal works at: http://digitalcommos.ohsu.edu/csetech

More information

the beginning of the program in order for it to work correctly. Similarly, a Confirm

the beginning of the program in order for it to work correctly. Similarly, a Confirm I our sytax, a Assume statemet will be used to record what must be true at the begiig of the program i order for it to work correctly. Similarly, a Cofirm statemet is used to record what should be true

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

A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON

A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON Roberto Lopez ad Eugeio Oñate Iteratioal Ceter for Numerical Methods i Egieerig (CIMNE) Edificio C1, Gra Capitá s/, 08034 Barceloa, Spai ABSTRACT I this work

More information

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software Structurig Redudacy for Fault Tolerace CSE 598D: Fault Tolerat Software What do we wat to achieve? Versios Damage Assessmet Versio 1 Error Detectio Iputs Versio 2 Voter Outputs State Restoratio Cotiued

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

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

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

Lecture 5: Recursion. Recursion Overview. Recursion is a powerful technique for specifying funclons, sets, and programs

Lecture 5: Recursion. Recursion Overview. Recursion is a powerful technique for specifying funclons, sets, and programs CS/ENGRD 20 Object- Orieted Programmig ad Data Structures Sprig 202 Doug James Visual Recursio Lecture : Recursio http://seredip.brymawr.edu/exchage/files/authors/faculty/39/literarykids/ifiite_mirror.jpg!

More information

Assignment 5; Due Friday, February 10

Assignment 5; Due Friday, February 10 Assigmet 5; Due Friday, February 10 17.9b The set X is just two circles joied at a poit, ad the set X is a grid i the plae, without the iteriors of the small squares. The picture below shows that the iteriors

More information

The Semantics of an FP Language with Infinite Objects

The Semantics of an FP Language with Infinite Objects The Sematics of a FP Laguage with Ifiite Objects TR88-022 April 1988 Teresa Ae Thomas The Uiversity of North Carolia at Chapel Hill Departmet of Computer Sciece CB#3175, Sitterso Hall Chapel Hill, NC 27599-3175

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