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

Size: px
Start display at page:

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

Transcription

1 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 checkig Type safety Type equivalece Remember, we are ow i the world of vo Neuma laguages usig value model for variables! Fall 18 CSCI 4430, A Milaova/BG Ryder 1 2 Lecture Outlie Type equivalece Types i C Primitive types Composite types Records (Structures i C) Variats (Uios i C) Arrays Poiters 3 Types Read: Scott, Chapters 7 ad 8 4 Type Equivalece Structural 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 defiitio Strict ame equivalece T1 x; T2 y; Loose ame 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 types (i.e., argumets are structurally equivalet) After type declaratio type = T or typedef T i C, the type ame is structurally equivalet to T Declaratio makes a alias of T. ad T are said to be aliased types 5 6 x = y; Fall 18 CSCI 4430, A Milaova 1

2 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; Fall 18 CSCI 4430, A Milaova/BG Ryder This is a type defiitio: a applicatio of the array type costructor 7 Structural Equivalece Show by isomorphism of correspodig type trees Show the type trees of these costructed types Are these types structurally 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 8 Name Equivalece Name equivalece Roughly, based o lexical occurrece of type defiitio. A applicatio of a type costructor is a type defiitio. E.g., the red array[1..20] is oe type defiitio ad the blue array[1..20] is a differet type defiitio. type T = 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! Questio Name equivalece w,z,v: array [1..20] of it; x,y: array [1..20] of it; Are x ad w of equivalet type accordig to ame equivalece? Aswer: x ad w are of distict types. Fall 18 CSCI 4430, A Milaova/BG Ryder 9 Fall 18 CSCI 4430, A Milaova/BG Ryder 10 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 equivalet, is said to have loose ame equivalece (e.g., it ad Age would be same) 11 Exercise type cell = // record type type alik = poiter to cell type blik = alik p,q : poiter to cell r : alik s : blik t : poiter to cell u : alik Group p,q,r,s,t ito equiv. classes, accordig to structural equiv., strict ame equiv. ad loose ame equiv. 12 2

3 Example: Type Equivalece i C First, i the Algol family, field ames are part of the record/struct costructed type. E.g., the record types below are NOT eve structurally equivalet type A = record x,y : real ed; type B = record z,w : real ed; Type Equivalece i C Aoymous types are differetiated by iteral (compiler-geerated) type ames struct RecA typedef struct struct { char x; { char x; { char x; it y; it y; it y; } a; } RecB; } c; RecB b; This struct is of type ao1. What variables are of equivalet type accordig to the rules i C? Fall 18 CSCI 4430, A Milaova/BG Ryder 13 Fall 18 CSCI 4430, A Milaova/BG Ryder 14 Type Equivalece i C C uses structural equivalece for everythig, except uios ad structs, for which it uses loose ame equivalece struct A struct B { char x; { char x; it y; it y; } } typedef struct A C; typedef C *P; typedef struct B *Q; typedef struct A *R; typedef it Age; typedef it (*F) (it); Type Equivalece i C struct B { char x; it y; }; typedef struct B A; struct { A a; A *ext; } aa; struct { struct B a; struct B *ext; } bb; struct { struct B a; struct B *ext; } cc; A a; struct B b; a = b; aa = bb; bb = cc; typedef Age (*G) (Age); Which of the above assigmets pass the type checker? Questio Structural equivalece for record types is cosidered a bad idea. Ca you thik of a reaso why? Type Equivalece ad Type Compatibility Questios: e := expressio þ or ý Are e ad expressio of same type? e ad expressio may ot be of equivalet types, but they may be of compatible types. It may be possible to covert the type of expressio to the type of e Fall 18 CSCI 4430, A Milaova 17 Fall 18 CSCI 4430, A Milaova/BG Ryder 18 3

4 Type Coversio Implicit coversio coercio Coversio doe implicitly by the compiler I C, mixed mode umerical operatios I e = expressio if e is a double ad expressio is a it, expressio is implicitly coerced i to a double double d,e; e = d + 2; //2 coerced to 2.0 Type Coversio Explicit coversio Programmer must ackowledge coversio I Pascal, roud ad truc perform explicit coversio roud(s) real to it by roudig truc(s) real to it by trucatig it to double, float to double How about float to it? No. May lose precisio ad thus, caot be coerced! I C, type castig performs explicit coversio freelist *s;... (char *)s; forces s to be cosidered as poitig to a char for the purposes of poiter arithmetic Fall 18 CSCI 4430, A Milaova/BG Ryder 19 Fall 18 CSCI 4430, A Milaova/BG Ryder 20 Lecture Outlie Type equivalece Types i C Primitive types Composite types Records (Structures i C) Variats (Uios i C) Arrays Poiters 21 Poiters: Poiters ad Arrays i C Poiters ad arrays are iteroperable: it ; it *a it b[10]; 1. a = b; 2. = a[3]; 3. = *(a+3); 4. = b[3]; 5. = *(b+3); Fall 18 CSCI 4430, A Milaova/BG Ryder 22 Type Declaratio i C What is the meaig of the followig declaratio i C? Draw the type trees. 1. it *a[] 2. it (*a)[] 3. it (*f)(it) Type Declaratio i C typedef it (*PFB)(); // Type variable PFB: what type? struct parse_table { // Type struct parse_table: what type? char *ame; PFB fuc; }; it fuc1() {... } // Fuctio fuc1: what type? it fuc2() {... } struct parse_table table[] = { // Variable table: what type? {"ame1", &fuc1}, {"ame2", &fuc2} }; PFB fid_p_fuc(char *s) { // Fuctio fid_p_fuc: what type? for (i=0; i<um_fuc; i++) if (strcmp(table[i].ame,s)==0) retur table[i].fuc; retur NULL; } it mai(it argc,char *argv[]) {... } Fall 18 CSCI 4430, A Milaova/BG Ryder 23 Fall 18 CSCI 4430, A Milaova 24 4

5 Type Declaratios i C Exercise Type tree for PFB: poiterto () it Type tree for type of fid_p_fuc: Eglish: a fuctio that takes a poiter to char as argumet, ad returs a poiter to a fuctio that takes void as argumet ad returs it. poiterto char poiterto () it struct _chuk { // Type struct_chuk: what type? char ame[10]; it id; }; struct obstack { // Type struct obstack: what type? struct _chuk *chuk; struct _chuk *(*chukfu)(); void (*freefu) (); }; void chuk_fu(struct obstack *h, void *f) { // Fuctio chuk_fu: what type? h->chukfu = (struct _chuk *(*)()) f; } void free_fu(struct obstack *h, void *f) { // Fuctio free_fu: what type? h->freefu = (void (*)()) f; } it mai() { struct obstack h; chuk_fu(&h,&xmalloc); free_fu(&h,&xfree);... } Fall 18 CSCI 4430, A Milaova 25 Fall 18 CSCI 4430, A Milaova 26 Type Declaratios i C Lecture Outlie poiterto Type tree for type of field chukfu: () poiterto struct _chuk: struct ame: array id: it char Fall 18 CSCI 4430, A Milaova 27 Type equivalece Types i C Primitive types Composite types Records (Structures i C) Variats (Uios i C) Arrays Poiters 28 Primitive Types A small collectio of built-i types iteger, float/real, etc. Desig issues: e.g., boolea Use iteger 0/o-0 vs. true/false? Implemetatio issues: represetatio i the machie Iteger Legth fixed by stadards or implemetatio (portability issues) Multiple legths (C: short, it, log) Sigs Float/real All issues of itegers ad more Composite Types: Record (Struct) Collectio of heterogeeous fields Operatios Selectio through field ames (s.um, p->ext) Assigmet Fall 18 CSCI 4430, A Milaova/BG Ryder Example: structures i C typedef struct cell listcell; struct cell { it um; listcell *ext; } s,t; s.um = 0; s.ext = 0; t = s; 5

6 Record (Struct) Variat (Uio) Defiitio of type. What is part of the type? order ad type of fields (but ot the ame) ame ad type of fields order, ame ad type of fields Implemetatio issues: memory layout Successive memory locatios at offset from first byte. Usually, word-aliged, but sometimes packed typedef struct { char ame[10]; it age; } Perso; Perso p; 4 bytes/32 bits ame holes Allow a collectio of alterative fields; oly oe alterative is valid durig executio Fortra: equivalece Algol68 ad C: uios Pascal: variat records Problem: how ca we assure type-safety? Pascal ad C are ot type-safe Algol68 is type-safe! Uses ru-time checks Usually alteratives use same storage Mutually exclusive value access age Fall 18 CSCI 4430, A Milaova/BG Ryder 31 Fall 18 CSCI 4430, A Milaova/BG Ryder 32 Variats (Uios) Example: uios i C uio data { it k; char c; } d1,d2; Operatios Selectio through field ames, Assigmet: d1.k = 3; d2 = d1; d2.c = b ; What about type safety? if (>0) d1.k=5 else d1.c= a ; d1.k << 2 // What is the problem? 33 Pascal s Variat Record program mai(iput,output); type paytype = (salaried,hourly); var employee : record id : iteger; Type tag dept: iteger; age : iteger; case payclass: paytype of salaried: (mothlyrate : real; startdate : iteger); hourly: (rateperhour : real; reghours : iteger; overtime : iteger); ed; begi employee.id:=001234; employee.dept:=12; employee.age:=38; employee.payclass:=hourly; employee.rateperhour:=2.75; employee.reghours:=40; employee.overtime:=3; writel(employee.rateperhour, employee.reghours, employee.overtime); {this should bomb as there is o mothlyrate because payclass=hourly} writel(employee.mothlyrate); Output: E Fall 18 CSCI 4430, A Milaova/BG Ryder E Pascal Variat Record type paytype = (salaried,hourly); var employee : record id : iteger; dept: iteger; age : iteger; case payclass: paytype of salaried:( mothlyrate : real; startdate : iteger); hourly: ( rateperhour : real; reghours : iteger; overtime : iteger); ed; employee.payclass:=salaried; employee.mothlyrate:=575.0; employee.startdate:=13085; {this should bomb as there are o rateperhour, etc. because payclass=salaried} writel(employee.rateperhour, employee.reghours employee.overtime); writel(employee.mothlyrate); ed. Output: E E+02 Algol68 Discrimiated Uios uio(it, real, bool) kitchesik; kitchesik := 3; kitchesik := 3.14; kitchesik := true; if radom <.5 the kitchesik := 1 else kitchesik := 2.78 fi; case kitchesik i (it j): prit (( iteger,j)); (real r): prit (( real,r)); (bool b): prit (( bool,b)); esac; Fall 18 CSCI 4430, A Milaova/BG Ryder 35 Fall 18 CSCI 4430, A Milaova/BG Ryder 36 6

7 Composite Types: Array Array Homogeeous, idexed collectio of values Access to idividual elemets through subscript There are may desig choices Subscript sytax Subscript type, elemet type Whe to set bouds, compile time or ru time? How to iitialize? What built-i operatios are allowed? Defiitio of type. What is part of the type? bouds/dimesio/elemet type Pascal dimesio/elemet type C, FORTRAN, Algol68 What is the lifetime of the array? Global lifetime, static shape (i static memory) Local lifetime (i stack memory) Static shape (stored i fixed-legth portio of stack frame) Shape boud whe cotrol eters a scope (e.g., Ada, Fortra allow defiitio of array bouds whe fuctio is etered; stored i variable-legth portio of stack frame) Global lifetime, dyamic shape (i heap memory) Fall 18 CSCI 4430, A Milaova/BG Ryder 37 Fall 18 CSCI 4430, A Milaova/BG Ryder 38 Example: Algol68 Arrays Array type icludes dimesio ad elemet type; it does ot iclude bouds [1:12] it moth; [1:7] it day; row it [0:10,0:10] real matrix; [-4:10,6:9] real table; row row real Note table ad matrix are equivalet! Example - [1:10] [1:5,1:5] it kiglear; What is the type of kiglear? What is the type of kiglear[j]? What is the type of kiglear[j][1,2]? kiglear[1,2,3]? Example: Algol68 Arrays Trimmig: yields some cross sectio of a origial Algol68 array (slicig a array ito subarrays) Subscriptig: limitig 1 dimesio to a sigle idex value [1:10]it a,b;[1:20]real x; [1:20,1:20]real xx; b[1:4] := a[1:4] assigs first 4 elemets of a ito first 4 elemets of b b := a? b[1:10]:= a[1:10] -? xx[4,1:20]:= x? xx[8:9,7] := x[1:2] assigs x[1] ito xx[8,7] ad x[2] ito xx[9,7] Fall 18 CSCI 4430, A Milaova/BG Ryder 39 Fall 18 CSCI 4430, A Milaova/BG Ryder 40 Array Addressig Oe dimesioal array X[low:high] each elemet is E bytes Assumig that elemets are stored ito cosecutive memory locatios, startig at address addr(x[low]), what is the address of X[j]? addr(x[low]) + (j-low)*e E.g, let X[0:10] be a array of reals (4 bytes) X[3]? is addr(x[0]) + (3-0)*4 = addr(x) + 12 X[1] is at address addr(x[0]) + 4 X[2] is at address addr(x[0]) + 8, etc Fall 18 CSCI 4430, A Milaova/BG Ryder 41 Array Addressig Memory is a sequece of cotiguous locatios Two memory layouts for two-dimesioal arrays: Row-major order ad colum-major order Row-major order: y[0,0], y[0,1], y[0,2],, y[0,], y[1,*], y[2,*], y[low1:hi1,low2:hi2] i Algol68, locatio y[j,k] is addr(y[low1,low2]) + (hi2-low2+1)*e*(j-low1) + (k-low2)*e #locs per row #rows i frot # elemets i row j i of row j frot of elemet [j,k] Fall 18 CSCI 4430, A Milaova/BG Ryder 42 7

8 Array Addressig Composite Types: Poiters Cosider y[0:2, 0:5] it matrix. Assume row-major order ad fid the address of y[1,3]. address of y[1,3] = addr(y[0,0])+(5-0+1)*4*(1-0)+(3-0)*4 6 elemets per row 1 row before row 1 3 elemets i row 1 before 3 = addr(y[0,0]) = addr(y[0,0])+36 Aalogous formula holds for colum-major order Row-major ad colum-major layouts geeralize to A variable or field whose value is a referece to some memory locatio I C: it *p; Operatios Allocatio ad deallocatio of objects o heap p = malloc(sizeof(it)); free(p); Assigmet of oe poiter ito aother it *q = p; it *p = &a; Dereferecig of poiter *q = 1; Poiter arithmetic p + 2 -dimesioal arrays Poiters: Recursive Types A recursive type is a type whose objects may cotai objects of the same type Necessary to build liked structures such as liked lists Poiters are ecessary to defie recursive types i laguages that use the value model for variables: struct cell { it um; struct cell *ext; } Poiters: Recursive Types Recursive types are defied aturally i laguages that use the referece model for variables: class Cell { it um; Cell ext; } Cell() { } Fall 18 CSCI 4430, A Milaova/BG Ryder 45 Fall 18 CSCI 4430, A Milaova/BG Ryder 46 8

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

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

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

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

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

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

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

Types-2. Type Equivalence

Types-2. Type Equivalence Types-2 Type equivalence Structural Name Algol68 Arrays Array addressing User-defined modes Discriminated unions Dereferencing as type conversion 1 Type Equivalence Structural equivalence SE1: a type name

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

High-Order Language APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL

High-Order Language APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL Chapter 2 C High-Order Laguage APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL 6 ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL MICROCODE LEVEL LOGIC GATE LEVEL Figure 2. 7 6 5 4

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

Data Structures and Algorithms. Analysis of Algorithms

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

More information

Computers and Scientific Thinking

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

More information

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria.

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria. Computer Sciece Foudatio Exam August, 005 Computer Sciece Sectio A No Calculators! Name: SSN: KEY Solutios ad Gradig Criteria Score: 50 I this sectio of the exam, there are four (4) problems. You must

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

Matrix representation of a solution of a combinatorial problem of the group theory

Matrix representation of a solution of a combinatorial problem of the group theory Matrix represetatio of a solutio of a combiatorial problem of the group theory Krasimir Yordzhev, Lilyaa Totia Faculty of Mathematics ad Natural Scieces South-West Uiversity 66 Iva Mihailov Str, 2700 Blagoevgrad,

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

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

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

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

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

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

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

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

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

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

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

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

EE University of Minnesota. Midterm Exam #1. Prof. Matthew O'Keefe TA: Eric Seppanen. Department of Electrical and Computer Engineering

EE University of Minnesota. Midterm Exam #1. Prof. Matthew O'Keefe TA: Eric Seppanen. Department of Electrical and Computer Engineering EE 4363 1 Uiversity of Miesota Midterm Exam #1 Prof. Matthew O'Keefe TA: Eric Seppae Departmet of Electrical ad Computer Egieerig Uiversity of Miesota Twi Cities Campus EE 4363 Itroductio to Microprocessors

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

! Given the following Structure: ! We can define a pointer to a structure. ! Now studentptr points to the s1 structure.

! Given the following Structure: ! We can define a pointer to a structure. ! Now studentptr points to the s1 structure. Liked Lists Uit 5 Sectios 11.9 & 18.1-2 CS 2308 Fall 2018 Jill Seama 11.9: Poiters to Structures! Give the followig Structure: struct Studet { strig ame; // Studet s ame it idnum; // Studet ID umber it

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

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

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

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

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

Convex hull ( 凸殻 ) property

Convex hull ( 凸殻 ) property Covex hull ( 凸殻 ) property The covex hull of a set of poits S i dimesios is the itersectio of all covex sets cotaiig S. For N poits P,..., P N, the covex hull C is the give by the expressio The covex hull

More information

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago CMSC 22200 Computer Architecture Lecture 12: Virtual Memory Prof. Yajig Li Uiversity of Chicago A System with Physical Memory Oly Examples: most Cray machies early PCs Memory early all embedded systems

More information

The Implementation of Data Structures in Version 5 of Icon* Ralph E. Gr is wo Id TR 85-8

The Implementation of Data Structures in Version 5 of Icon* Ralph E. Gr is wo Id TR 85-8 The Implemetatio of Data Structures i Versio 5 of Ico* Ralph E. Gr is wo Id TR 85-8 April 1, 1985 Departmet of Computer Sciece The Uiversity of Arizoa Tucso. Arizoa 85721 This work was supported by the

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

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

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

More information

Chapter 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

UNIVERSITY OF MORATUWA

UNIVERSITY OF MORATUWA UNIVERSITY OF MORATUWA FACULTY OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING B.Sc. Egieerig 2014 Itake Semester 2 Examiatio CS2052 COMPUTER ARCHITECTURE Time allowed: 2 Hours Jauary 2016

More information

Programming with Shared Memory PART II. HPC Spring 2017 Prof. Robert van Engelen

Programming with Shared Memory PART II. HPC Spring 2017 Prof. Robert van Engelen Programmig with Shared Memory PART II HPC Sprig 2017 Prof. Robert va Egele Overview Sequetial cosistecy Parallel programmig costructs Depedece aalysis OpeMP Autoparallelizatio Further readig HPC Sprig

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

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

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

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

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

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

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

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

1. (a) Write a C program to display the texts Hello, World! on the screen. (2 points)

1. (a) Write a C program to display the texts Hello, World! on the screen. (2 points) 1. (a) Write a C program to display the texts Hello, World! o the scree. (2 poits) Solutio 1: pritf("hello, World!\"); Solutio 2: void mai() { pritf("hello, World!\"); (b) Write a C program to output a

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

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

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

FURTHER INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS)

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

More information

Random Graphs and Complex Networks T

Random Graphs and Complex Networks T Radom Graphs ad Complex Networks T-79.7003 Charalampos E. Tsourakakis Aalto Uiversity Lecture 3 7 September 013 Aoucemet Homework 1 is out, due i two weeks from ow. Exercises: Probabilistic iequalities

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

End Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization

End Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization Ed Semester Examiatio 2013-14 CSE, III Yr. (I Sem), 30002: Computer Orgaizatio Istructios: GROUP -A 1. Write the questio paper group (A, B, C, D), o frot page top of aswer book, as per what is metioed

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

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

Lower Bounds for Sorting

Lower Bounds for Sorting Liear Sortig Topics Covered: Lower Bouds for Sortig Coutig Sort Radix Sort Bucket Sort Lower Bouds for Sortig Compariso vs. o-compariso sortig Decisio tree model Worst case lower boud Compariso Sortig

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

Consider the following population data for the state of California. Year Population

Consider the following population data for the state of California. Year Population Assigmets for Bradie Fall 2016 for Chapter 5 Assigmet sheet for Sectios 5.1, 5.3, 5.5, 5.6, 5.7, 5.8 Read Pages 341-349 Exercises for Sectio 5.1 Lagrage Iterpolatio #1, #4, #7, #13, #14 For #1 use MATLAB

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

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

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

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

COMP Parallel Computing. PRAM (1): The PRAM model and complexity measures

COMP Parallel Computing. PRAM (1): The PRAM model and complexity measures COMP 633 - Parallel Computig Lecture 2 August 24, 2017 : The PRAM model ad complexity measures 1 First class summary This course is about parallel computig to achieve high-er performace o idividual problems

More information

NAG Library Function Document nag_fft_hermitian (c06ebc)

NAG Library Function Document nag_fft_hermitian (c06ebc) c06 Fourier Trasforms NAG Library Fuctio Documet ag_fft_hermitia () 1 Purpose ag_fft_hermitia () calculates the discrete Fourier trasform of a Hermitia sequece of complex data values. (No extra workspace

More information

Priority Queues. Binary Heaps

Priority Queues. Binary Heaps Priority Queues Biary Heaps Priority Queues Priority: some property of a object that allows it to be prioritized with respect to other objects of the same type Mi Priority Queue: homogeeous collectio of

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

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

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

Major CSL Write your name and entry no on every sheet of the answer script. Time 2 Hrs Max Marks 70

Major CSL Write your name and entry no on every sheet of the answer script. Time 2 Hrs Max Marks 70 NOTE:. Attempt all seve questios. Major CSL 02 2. Write your ame ad etry o o every sheet of the aswer script. Time 2 Hrs Max Marks 70 Q No Q Q 2 Q 3 Q 4 Q 5 Q 6 Q 7 Total MM 6 2 4 0 8 4 6 70 Q. Write a

More information

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

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

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

Data Structures Week #9. Sorting

Data Structures Week #9. Sorting Data Structures Week #9 Sortig Outlie Motivatio Types of Sortig Elemetary (O( 2 )) Sortig Techiques Other (O(*log())) Sortig Techiques 21.Aralık.2010 Boraha Tümer, Ph.D. 2 Sortig 21.Aralık.2010 Boraha

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

The Adjacency Matrix and The nth Eigenvalue

The Adjacency Matrix and The nth Eigenvalue Spectral Graph Theory Lecture 3 The Adjacecy Matrix ad The th Eigevalue Daiel A. Spielma September 5, 2012 3.1 About these otes These otes are ot ecessarily a accurate represetatio of what happeed i class.

More information