News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example
|
|
- Beverly Powers
- 6 years ago
- Views:
Transcription
1 Unversty of Brtsh Columba CPSC, Intro to Computaton Jan-Apr Tamara Munzner News Assgnment correctons to ASCIIArtste.java posted defntely read WebCT bboards Arrays Lecture, Tue Feb based on sldes by Kurt Eselt Readng Ths week:.,.-., topcs. and. Recap: Whle Loop Example publc class WhleDemo publc statc vod man (Strng[] args) nt lmt = ; nt counter = ; whle (counter <= lmt) System.out.prntln("The square of " + counter + " s " + (counter * counter)); counter = counter + ; System.out.prntln("End of demonstraton"); whle verson Recap: For Loop Example publc class ForDemo publc statc vod man (Strng[] args) for (nt counter = ; counter <= ; counter = counter + ) System.out.prntln("The square of " + counter + " s " + (counter * counter)); System.out.prntln("End of demonstraton"); for verson Recap: Do Loop Example publc class DoDemo publc statc vod man (Strng[] args) nt lmt = ; nt counter = ; do System.out.prntln("The square of " + counter + " s " + (counter * counter)); counter = counter + ; whle (counter <= lmt); System.out.prntln("End of demonstraton"); do verson
2 Recap: For Statement for (ntalzaton; boolean expresson; ncrement) body Body of loop can be sngle statement whole block of many statements n curly braces Control flow frst tme through: ntalzaton boolean expresson evaluated f expresson true, body executed; f false, end ncrement processed boolean expresson evaluated f true, body executed; f false, end. Recap: For Versus Whle Statement how for statement works ntalzaton boolean expresson boolean expresson true false true how whle statement works false statement statement ncrement flowcharts can be somewhat deceptve need ntalzaton and ncrementng/modfyng n whle loop too although syntax does not requre t n specfc spot Recap: Do Statement Objectves ntalze do useful stuff Body always executed at least once false More practce wth loops Understand when and how to use arrays and loops over arrays test true get closer to termnaton order of four thngs can change, but need them all Flppng Cons Keepng Track of Thngs Cans of pop sold ths month Dd whle verson last tme Let's try for verson now What s the gross ncome? What s the net proft? Is Bubba stealng loones?
3 Keepng Track of Thngs Cans of pop sold ths month Answer: Arrays Cans of pop sold ths month use arrays: common programmng language construct groupng related data tems together meanngful organzaton such that each ndvdual data tem can be easly retreved or updated In other words, how can I organze the data above n my computer so that I can access t easly and do the computatons I need to do? Answer: Arrays use arrays: common programmng language construct all of same type share common name each varable holds sngle value Usng Arrays Collecton of varables has sngle name how do we access ndvdual values? Each value stored at unque numbered poston number called ndex of array element Collecton of varables has sngle name how do we access ndvdual values? collecton of varables groupng related data tems together meanngful organzaton such that each ndvdual data tem can be easly retreved or updated Usng Arrays Usng Arrays To access ndvdual value n array use array name followed by par of square brackets nsde brackets, place ndex of array element we want to access Reference to array element allowed anywhere that varables can be used Example: aka subscrpt name of ths array holds values System.out.prntln([]); Prnts value
4 Array Declaraton and Types Just lke ordnary varable, must declare array before we use t gve array a type Snce contans ntegers, make nteger array: nt[] = new nt[] Looks lke varable declaraton, except: Array Declaraton and Types Just lke ordnary varable, must declare array before we use t gve array a type Snce contans ntegers, make nteger array: nt[] = new nt[] Looks lke varable declaraton, except: empty brackets on the left tell Java that s an array... Array Declaraton and Types Just lke ordnary varable, must declare array before we use t gve array a type Snce contans ntegers, make nteger array: nt[] = new nt[] Looks lke varable declaraton, except: empty brackets on the left tell Java that s an array... the number n the brackets on the rght tell Java that array should have room for elements when t's created Array Declaraton and Types Just lke ordnary varable, must declare array before we use t gve array a type Snce contans ntegers, make nteger array: nt[] = new nt[] Looks lke varable declaraton, except: empty brackets on the left tell Java that s an array... the number n the brackets on the rght tell Java that array should have room for elements when t's created DO NOT put sze of array n brackets on the left Array Declaraton and Types Just lke ordnary varable, must declare array before we use t gve array a type Snce contans ntegers, make nteger array: nt[] = new nt[] Looks lke varable declaraton, except: empty brackets on the left tell Java that s an array... the number n the brackets on the rght tell Java that array should have room for elements when t's created DO NOT put sze of array n brackets on the left Array Declaraton and Types publc class ArrayTest fnal nt ARRAYSIZE = ; nt[] = new nt[arraysize]; [] = ; [] = ; [] = ; [] = ; [] = ; [] = ; [] = ; [] = ; [] = ; [] = ; // do useful stuff here System.out.prntln("Element s " + []);
5 Array Declaraton and Types publc class ArrayTest nt[] =,,,,,,,,, ; // do useful stuff here System.out.prntln("Element s " + []); Can also use ntalzer lst Rght sde of declaraton does not nclude type or sze Java fgures out sze by tself Types of values on rght must match type declared on left Intalzer lst may only be used when array s frst declared Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result nt[] =,,,,,,,,, ;
6 Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result nt[] =,,,,,,,,, ; for (nt = ; Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result nt[] =,,,,,,,,, ; for (nt = ; <.length; Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; Usng Arrays and Loops Wrte program to create array fnd total number of cans sold prnt result nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];
7 nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans Is <? yes, <.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans
8 .length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans Is <? yes, < totalcans.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans Is <? yes, <.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans
9 .length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans Is <? yes, < totalcans.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans Is <? yes, <.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans And so on totalcans And so on
10 .length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans And so on totalcans And so on.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans And so on totalcans And so on.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + []; totalcans totalcans Is <? no, not <
11 .length nt[] =,,,,,,,,, ; for (nt = ; <.length; ++) totalcans = totalcans + [];.length nt[] =,,,,,,,,, ; for (nt = ; <=.length; ++) totalcans = totalcans + []; totalcans "We've sold cans of pop" prnted out totalcans What would happen f we made ths lttle change? Somethng To Remember.length nt[] =,,,,,,,,, ; for (nt = ; <=.length; ++) totalcans = totalcans + []; totalcans What would happen f we made ths lttle change?.length Array created wth elements Indces (plural of ndex) are through In general, array of sze n wll have ndces rangng from through n- When you number thngs, you're used to begnnng wth Computer folks begn wth leads to "off by one" errors, even among computer veterans java.lang.arrayindexoutofboundsexcepton: Intalzng Array Wth Keyboard Input Averagng Loop Example mport java.utl.scanner; b fnal nt ARRAYSIZE = ; nt[] = new nt[arraysize]; Scanner scan = new Scanner(System.n); for (nt = ; <.length; ++) System.out.prnt("Enter machne " + (+)); [] = scan.nextint(); // do useful stuff here System.out.prntln("Element s " + []); numbers Let's say we want to wrte a program that prnts average of values n some arbtrarly large array lke the one to the left called numbers Wll requre loop Smple task for loopng n the context of an array how wll we make ths happen?
12 numbers PrntMax Loop Example Now nstead of average, we want to fnd and prnt maxmum value from some arbtrarly large array Smlar loop, but wth some extra tweaks. numbers Hstogram Loop Example ****** ******** *********** ****************** ******************** ***************** ************** ********** ***** ** Now use same data as bass for hstogram Wrte one loop to look at value assocated wth each row of array for each value prnt a lne wth that many astersks For example, f program reads value from the array, should prnt lne of astersks Program then reads the value, prnts a lne of astersks, and so on. Need outer loop to read ndvdual values n the array Need nner loop to prnt astersks for each value Storng Dfferent Data Types Storng Dfferent Data Types Could use two arrays of same sze but wth dfferent types Storng Dfferent Data Types Storng Dfferent Data Types Could use two arrays of same sze but wth dfferent types Wrte program to compare what's been collected from each machne vs. how much should have been collected? Could use two arrays of same sze but wth dfferent types Wrte program to compare what's been collected from each machne vs. how much should have been collected? publc class ArrayTest double expected; nt[] =,,,,,,,,, ; double[] =.,.,.,.,.,.,.,.,.,.; for (nt = ; <.length; ++) expected = [] *.; System.out.prntln("Machne " + ( + ) + " off by $" + (expected - []));
13 Storng Dfferent Data Types Could use two arrays of same sze but wth dfferent types What happens when we run the program? Wrte program to compare what's been collected from each machne vs. how much should have been collected? publc class ArrayTest double expected; nt[] =,,,,,,,,, ; double[] =.,.,.,.,.,.,.,.,.,.; for (nt = ; <.length; ++) expected = [] *.; System.out.prntln("Machne " + ( + ) + " off by $" + (expected - [])); Storng Dfferent Data Types Somebody has been stealng from the machnes after all We need an ant-theft plan Machne off by $. Machne off by $. Machne off by $. Machne off by $. Machne off by $. Machne off by $. Machne off by $. Machne off by $. Machne off by $. Machne off by $. Arrays Wth Non-Prmtve Types Arrays Wth Non-Prmtve Types Great f you're always storng prmtves lke ntegers or floatng pont numbers What f we want to store Strng types too? remember that Strng s an object, not a prmtve data type locaton Then we create array of objects In ths case objects wll be Strngs Array won't hold actual object holds references: ponters to objects Strng[] locaton = new Strng[]; Arrays of Objects Arrays of Objects locaton Now we can put references to Strngs n our Strng array locaton Now we can put references to Strngs n our Strng array. "Law School" locaton[] = ; locaton[] = ; locaton[] = "Law School";
14 Arrays of Objects Arrays of Objects locaton "Man Lbrary" "Law School" locaton "Law School" "Man Lbrary" "Koerner Lbrary" "Busness" "Bology" Now we can put references to Strngs n our Strng array. locaton[] = ; locaton[] = "Law School"; locaton[] = "Man Lbrary"; Now we can put references to Strngs n our Strng array. locaton[] = ; locaton[] = "Law School"; locaton[] = "Man Lbrary"; "Educaton" "Appled Scence" "Agrculture"...and so on... "Computer Scence" Arrays of Objects Arrays of Objects locaton "Law School" "Man Lbrary" "Koerner Lbrary" "Busness" "Bology" locaton "Law School" "Man Lbrary" "Koerner Lbrary" "Busness" "Bology" Or we could have done ths: Strng[] locaton =, "Law School", "Man Lbrary",... ; "Educaton" "Appled Scence" "Agrculture" "Computer Scence" Each ndvdual Strng object n array of course has all Strng methods avalable For example, what would ths return? locaton[].length() "Educaton" "Appled Scence" "Agrculture" "Computer Scence" Arrays of Objects Each ndvdual Strng object n array of course has all Strng methods avalable For example, what would ths return? locaton[].length() locaton "Man Lbrary" "Busness" "Law School" "Bology" "Educaton" "Appled Scence" "Koerner Lbrary" "Agrculture" "Computer Scence" locaton Arrays of Objects Thnk about a cleaner way to do all ths "Man Lbrary" "Busness" "Law School" "Bology" "Educaton" "Appled Scence" "Koerner Lbrary" "Agrculture" "Computer Scence"
Midterms Save the Dates!
Unversty of Brtsh Columba CPSC, Intro to Computaton Alan J. Hu Readngs Ths Week: Ch 6 (Ch 7 n old 2 nd ed). (Remnder: Readngs are absolutely vtal for learnng ths stuff!) Thnkng About Loops Lecture 9 Some
More informationPass by Reference vs. Pass by Value
Pass by Reference vs. Pass by Value Most methods are passed arguments when they are called. An argument may be a constant or a varable. For example, n the expresson Math.sqrt(33) the constant 33 s passed
More informationMidterms Save the Dates!
Unversty of Brtsh Columba CPSC, Intro to Computaton Alan J. Hu Thnkng About Loops Intro to Arrays (Obect References?) Readngs Ths Week: Ch 6 (Ch 7 n old 2 nd ed). Next Week: Ch 7 (Ch 8 n old 2 nd ed).
More informationOutline. CIS 110: Intro to Computer Programming. What Do Our Programs Look Like? The Scanner Object. CIS 110 (11fa) - University of Pennsylvania 1
Outlne CIS 110: Intro to Computer Programmng The Scanner Object Introducng Condtonal Statements Cumulatve Algorthms Lecture 10 Interacton and Condtonals ( 3.3, 4.1-4.2) 10/15/2011 CIS 110 (11fa) - Unversty
More informationCMPS 10 Introduction to Computer Science Lecture Notes
CPS 0 Introducton to Computer Scence Lecture Notes Chapter : Algorthm Desgn How should we present algorthms? Natural languages lke Englsh, Spansh, or French whch are rch n nterpretaton and meanng are not
More informationAgenda & Reading. Simple If. Decision-Making Statements. COMPSCI 280 S1C Applications Programming. Programming Fundamentals
Agenda & Readng COMPSCI 8 SC Applcatons Programmng Programmng Fundamentals Control Flow Agenda: Decsonmakng statements: Smple If, Ifelse, nested felse, Select Case s Whle, DoWhle/Untl, For, For Each, Nested
More informationComputer models of motion: Iterative calculations
Computer models o moton: Iteratve calculatons OBJECTIVES In ths actvty you wll learn how to: Create 3D box objects Update the poston o an object teratvely (repeatedly) to anmate ts moton Update the momentum
More informationOutline. CIS 110: Introduction to Computer Programming. Review: Interactive Sum. More Cumulative Algorithms. Interactive Sum Trace (2)
Outlne CIS 110: Introducton to Computer Programmng More on Cumulatve Algorthms Processng Text Tacklng Programmng Problems Lecture 11 Text Processng and More On Desgn ( 4.2-4.3) 10/17/2011 CIS 110 (11fa)
More informationCHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar
CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vdyanagar Faculty Name: Am D. Trved Class: SYBCA Subject: US03CBCA03 (Advanced Data & Fle Structure) *UNIT 1 (ARRAYS AND TREES) **INTRODUCTION TO ARRAYS If we want
More informationFor instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1)
Secton 1.2 Subsets and the Boolean operatons on sets If every element of the set A s an element of the set B, we say that A s a subset of B, or that A s contaned n B, or that B contans A, and we wrte A
More informationNotes on Organizing Java Code: Packages, Visibility, and Scope
Notes on Organzng Java Code: Packages, Vsblty, and Scope CS 112 Wayne Snyder Java programmng n large measure s a process of defnng enttes (.e., packages, classes, methods, or felds) by name and then usng
More informationIntro. Iterators. 1. Access
Intro Ths mornng I d lke to talk a lttle bt about s and s. We wll start out wth smlartes and dfferences, then we wll see how to draw them n envronment dagrams, and we wll fnsh wth some examples. Happy
More informationBrave New World Pseudocode Reference
Brave New World Pseudocode Reference Pseudocode s a way to descrbe how to accomplsh tasks usng basc steps lke those a computer mght perform. In ths week s lab, you'll see how a form of pseudocode can be
More informationSequential search. Building Java Programs Chapter 13. Sequential search. Sequential search
Sequental search Buldng Java Programs Chapter 13 Searchng and Sortng sequental search: Locates a target value n an array/lst by examnng each element from start to fnsh. How many elements wll t need to
More informationCE 221 Data Structures and Algorithms
CE 1 ata Structures and Algorthms Chapter 4: Trees BST Text: Read Wess, 4.3 Izmr Unversty of Economcs 1 The Search Tree AT Bnary Search Trees An mportant applcaton of bnary trees s n searchng. Let us assume
More informationA Taste of Java and Object-Oriented Programming
Introducn Computer Scence Shm Schocken IDC Herzlya Lecture 1-2: Lecture 1-2: A Taste Java Object-Orented Programmng A Taste Java OO programmng, Shm Schocken, IDC Herzlya, www.ntro2cs.com slde 1 Lecture
More informationCS1100 Introduction to Programming
Factoral (n) Recursve Program fact(n) = n*fact(n-) CS00 Introducton to Programmng Recurson and Sortng Madhu Mutyam Department of Computer Scence and Engneerng Indan Insttute of Technology Madras nt fact
More informationHigh level vs Low Level. What is a Computer Program? What does gcc do for you? Program = Instructions + Data. Basic Computer Organization
What s a Computer Program? Descrpton of algorthms and data structures to acheve a specfc ojectve Could e done n any language, even a natural language lke Englsh Programmng language: A Standard notaton
More informationOverview. CSC 2400: Computer Systems. Pointers in C. Pointers - Variables that hold memory addresses - Using pointers to do call-by-reference in C
CSC 2400: Comuter Systems Ponters n C Overvew Ponters - Varables that hold memory addresses - Usng onters to do call-by-reference n C Ponters vs. Arrays - Array names are constant onters Ponters and Strngs
More informationTerminal Window. 11. Section 7 Exercises Program Memory Exercise 7-1 Swap Values in an Array Working memory Global Memory. 2 nd call 3 rd call
11. Secton 7 Exercses Program Memory Exercse 7-1 Swap Values n an Array Workng memory Global Memory class SwapTlYouDrop publc statc vod man (Strng args[ ]) nt = 0; nt a; a = new nt[] 2, 4, 6, 8, 10, 12
More informationCSCI 104 Sorting Algorithms. Mark Redekopp David Kempe
CSCI 104 Sortng Algorthms Mark Redekopp Davd Kempe Algorthm Effcency SORTING 2 Sortng If we have an unordered lst, sequental search becomes our only choce If we wll perform a lot of searches t may be benefcal
More informationAssembler. Building a Modern Computer From First Principles.
Assembler Buldng a Modern Computer From Frst Prncples www.nand2tetrs.org Elements of Computng Systems, Nsan & Schocken, MIT Press, www.nand2tetrs.org, Chapter 6: Assembler slde Where we are at: Human Thought
More informationHarvard University CS 101 Fall 2005, Shimon Schocken. Assembler. Elements of Computing Systems 1 Assembler (Ch. 6)
Harvard Unversty CS 101 Fall 2005, Shmon Schocken Assembler Elements of Computng Systems 1 Assembler (Ch. 6) Why care about assemblers? Because Assemblers employ some nfty trcks Assemblers are the frst
More informationELEC 377 Operating Systems. Week 6 Class 3
ELEC 377 Operatng Systems Week 6 Class 3 Last Class Memory Management Memory Pagng Pagng Structure ELEC 377 Operatng Systems Today Pagng Szes Vrtual Memory Concept Demand Pagng ELEC 377 Operatng Systems
More informationPriority queues and heaps Professors Clark F. Olson and Carol Zander
Prorty queues and eaps Professors Clark F. Olson and Carol Zander Prorty queues A common abstract data type (ADT) n computer scence s te prorty queue. As you mgt expect from te name, eac tem n te prorty
More information9. BASIC programming: Control and Repetition
Am: In ths lesson, you wll learn: H. 9. BASIC programmng: Control and Repetton Scenaro: Moz s showng how some nterestng patterns can be generated usng math. Jyot [after seeng the nterestng graphcs]: Usng
More informationToday s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss.
Today s Outlne Sortng Chapter 7 n Wess CSE 26 Data Structures Ruth Anderson Announcements Wrtten Homework #6 due Frday 2/26 at the begnnng of lecture Proect Code due Mon March 1 by 11pm Today s Topcs:
More informationAssignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.
Farrukh Jabeen Algorthms 51 Assgnment #2 Due Date: June 15, 29. Assgnment # 2 Chapter 3 Dscrete Fourer Transforms Implement the FFT for the DFT. Descrbed n sectons 3.1 and 3.2. Delverables: 1. Concse descrpton
More informationSLAM Summer School 2006 Practical 2: SLAM using Monocular Vision
SLAM Summer School 2006 Practcal 2: SLAM usng Monocular Vson Javer Cvera, Unversty of Zaragoza Andrew J. Davson, Imperal College London J.M.M Montel, Unversty of Zaragoza. josemar@unzar.es, jcvera@unzar.es,
More informationCS221: Algorithms and Data Structures. Priority Queues and Heaps. Alan J. Hu (Borrowing slides from Steve Wolfman)
CS: Algorthms and Data Structures Prorty Queues and Heaps Alan J. Hu (Borrowng sldes from Steve Wolfman) Learnng Goals After ths unt, you should be able to: Provde examples of approprate applcatons for
More informationCSE 326: Data Structures Quicksort Comparison Sorting Bound
CSE 326: Data Structures Qucksort Comparson Sortng Bound Bran Curless Sprng 2008 Announcements (5/14/08) Homework due at begnnng of class on Frday. Secton tomorrow: Graded homeworks returned More dscusson
More informationAMath 483/583 Lecture 21 May 13, Notes: Notes: Jacobi iteration. Notes: Jacobi with OpenMP coarse grain
AMath 483/583 Lecture 21 May 13, 2011 Today: OpenMP and MPI versons of Jacob teraton Gauss-Sedel and SOR teratve methods Next week: More MPI Debuggng and totalvew GPU computng Read: Class notes and references
More informationCS240: Programming in C. Lecture 12: Polymorphic Sorting
CS240: Programmng n C ecture 12: Polymorphc Sortng Sortng Gven a collecton of tems and a total order over them, sort the collecton under ths order. Total order: every tem s ordered wth respect to every
More informationGuidelines for Developing Effective Slide Presentations
Gudelnes for Developng Effectve Slde Presentatons Most presentatons consst of three man components: Content Vsuals Delvery Content Know your materal. No matter how great your presentaton looks, nothng
More informationInsertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array
Inserton Sort Dvde and Conquer Sortng CSE 6 Data Structures Lecture 18 What f frst k elements of array are already sorted? 4, 7, 1, 5, 1, 16 We can shft the tal of the sorted elements lst down and then
More informationPerformance Evaluation of Information Retrieval Systems
Why System Evaluaton? Performance Evaluaton of Informaton Retreval Systems Many sldes n ths secton are adapted from Prof. Joydeep Ghosh (UT ECE) who n turn adapted them from Prof. Dk Lee (Unv. of Scence
More informationA Binarization Algorithm specialized on Document Images and Photos
A Bnarzaton Algorthm specalzed on Document mages and Photos Ergna Kavalleratou Dept. of nformaton and Communcaton Systems Engneerng Unversty of the Aegean kavalleratou@aegean.gr Abstract n ths paper, a
More informationProgramming in Fortran 90 : 2017/2018
Programmng n Fortran 90 : 2017/2018 Programmng n Fortran 90 : 2017/2018 Exercse 1 : Evaluaton of functon dependng on nput Wrte a program who evaluate the functon f (x,y) for any two user specfed values
More informationComplex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.
Complex Numbers The last topc n ths secton s not really related to most of what we ve done n ths chapter, although t s somewhat related to the radcals secton as we wll see. We also won t need the materal
More informationLoop Transformations, Dependences, and Parallelization
Loop Transformatons, Dependences, and Parallelzaton Announcements Mdterm s Frday from 3-4:15 n ths room Today Semester long project Data dependence recap Parallelsm and storage tradeoff Scalar expanson
More informationArray transposition in CUDA shared memory
Array transposton n CUDA shared memory Mke Gles February 19, 2014 Abstract Ths short note s nspred by some code wrtten by Jeremy Appleyard for the transposton of data through shared memory. I had some
More informationVirtual Memory. Background. No. 10. Virtual Memory: concept. Logical Memory Space (review) Demand Paging(1) Virtual Memory
Background EECS. Operatng System Fundamentals No. Vrtual Memory Prof. Hu Jang Department of Electrcal Engneerng and Computer Scence, York Unversty Memory-management methods normally requres the entre process
More informationIntroduction to Programming. Lecture 13: Container data structures. Container data structures. Topics for this lecture. A basic issue with containers
1 2 Introducton to Programmng Bertrand Meyer Lecture 13: Contaner data structures Last revsed 1 December 2003 Topcs for ths lecture 3 Contaner data structures 4 Contaners and genercty Contan other objects
More informationAssembler. Shimon Schocken. Spring Elements of Computing Systems 1 Assembler (Ch. 6) Compiler. abstract interface.
IDC Herzlya Shmon Schocken Assembler Shmon Schocken Sprng 2005 Elements of Computng Systems 1 Assembler (Ch. 6) Where we are at: Human Thought Abstract desgn Chapters 9, 12 abstract nterface H.L. Language
More informationSorting. Sorted Original. index. index
1 Unt 16 Sortng 2 Sortng Sortng requres us to move data around wthn an array Allows users to see and organze data more effcently Behnd the scenes t allows more effectve searchng of data There are MANY
More informationMultiple optimum values
1.204 Lecture 22 Unconstraned nonlnear optmzaton: Amoeba BFGS Lnear programmng: Glpk Multple optmum values A B C G E Z X F Y D X 1 X 2 Fgure by MIT OpenCourseWare. Heurstcs to deal wth multple optma: Start
More informationCSE 326: Data Structures Quicksort Comparison Sorting Bound
CSE 326: Data Structures Qucksort Comparson Sortng Bound Steve Setz Wnter 2009 Qucksort Qucksort uses a dvde and conquer strategy, but does not requre the O(N) extra space that MergeSort does. Here s the
More informationEsc101 Lecture 1 st April, 2008 Generating Permutation
Esc101 Lecture 1 Aprl, 2008 Generatng Permutaton In ths class we wll look at a problem to wrte a program that takes as nput 1,2,...,N and prnts out all possble permutatons of the numbers 1,2,...,N. For
More informationThe Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique
//00 :0 AM Outlne and Readng The Greedy Method The Greedy Method Technque (secton.) Fractonal Knapsack Problem (secton..) Task Schedulng (secton..) Mnmum Spannng Trees (secton.) Change Money Problem Greedy
More informationUSING GRAPHING SKILLS
Name: BOLOGY: Date: _ Class: USNG GRAPHNG SKLLS NTRODUCTON: Recorded data can be plotted on a graph. A graph s a pctoral representaton of nformaton recorded n a data table. t s used to show a relatonshp
More informationCompiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz
Compler Desgn Sprng 2014 Regster Allocaton Sample Exercses and Solutons Prof. Pedro C. Dnz USC / Informaton Scences Insttute 4676 Admralty Way, Sute 1001 Marna del Rey, Calforna 90292 pedro@s.edu Regster
More informationOPL: a modelling language
OPL: a modellng language Carlo Mannno (from OPL reference manual) Unversty of Oslo, INF-MAT60 - Autumn 00 (Mathematcal optmzaton) ILOG Optmzaton Programmng Language OPL s an Optmzaton Programmng Language
More informationThis chapter discusses aspects of heat conduction. The equilibrium heat conduction on a rod. In this chapter, Arrays will be discussed.
1 Heat Flow n a Rod Ths chapter dscusses aspects of heat conducton. The equlbrum heat conducton on a rod. In ths chapter, Arrays wll be dscussed. Arrays provde a mechansm for declarng and accessng several
More informationMathematics 256 a course in differential equations for engineering students
Mathematcs 56 a course n dfferental equatons for engneerng students Chapter 5. More effcent methods of numercal soluton Euler s method s qute neffcent. Because the error s essentally proportonal to the
More informationSetup and Use. For events not using AuctionMaestro Pro. Version /7/2013
Verson 3.1.2 2/7/2013 Setup and Use For events not usng AuctonMaestro Pro MaestroSoft, Inc. 1750 112th Avenue NE, Sute A200, Bellevue, WA 98004 425.688.0809 / 800.438.6498 Fax: 425.688.0999 www.maestrosoft.com
More informationR s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes
SPH3UW Unt 7.3 Sphercal Concave Mrrors Page 1 of 1 Notes Physcs Tool box Concave Mrror If the reflectng surface takes place on the nner surface of the sphercal shape so that the centre of the mrror bulges
More informationAnalysis of Continuous Beams in General
Analyss of Contnuous Beams n General Contnuous beams consdered here are prsmatc, rgdly connected to each beam segment and supported at varous ponts along the beam. onts are selected at ponts of support,
More informationParallelism for Nested Loops with Non-uniform and Flow Dependences
Parallelsm for Nested Loops wth Non-unform and Flow Dependences Sam-Jn Jeong Dept. of Informaton & Communcaton Engneerng, Cheonan Unversty, 5, Anseo-dong, Cheonan, Chungnam, 330-80, Korea. seong@cheonan.ac.kr
More informationModule Management Tool in Software Development Organizations
Journal of Computer Scence (5): 8-, 7 ISSN 59-66 7 Scence Publcatons Management Tool n Software Development Organzatons Ahmad A. Al-Rababah and Mohammad A. Al-Rababah Faculty of IT, Al-Ahlyyah Amman Unversty,
More informationSupport Vector Machines
/9/207 MIST.6060 Busness Intellgence and Data Mnng What are Support Vector Machnes? Support Vector Machnes Support Vector Machnes (SVMs) are supervsed learnng technques that analyze data and recognze patterns.
More informationNachos Project 3. Speaker: Sheng-Wei Cheng 2010/12/16
Nachos Project Speaker: Sheng-We Cheng //6 Agenda Motvaton User Programs n Nachos Related Nachos Code for User Programs Project Assgnment Bonus Submsson Agenda Motvaton User Programs n Nachos Related Nachos
More informationOracle Database: SQL and PL/SQL Fundamentals Certification Course
Oracle Database: SQL and PL/SQL Fundamentals Certfcaton Course 1 Duraton: 5 Days (30 hours) What you wll learn: Ths Oracle Database: SQL and PL/SQL Fundamentals tranng delvers the fundamentals of SQL and
More informationProgramming Assignment Six. Semester Calendar. 1D Excel Worksheet Arrays. Review VBA Arrays from Excel. Programming Assignment Six May 2, 2017
Programmng Assgnment Sx, 07 Programmng Assgnment Sx Larry Caretto Mechancal Engneerng 09 Computer Programmng for Mechancal Engneers Outlne Practce quz for actual quz on Thursday Revew approach dscussed
More informationNGPM -- A NSGA-II Program in Matlab
Verson 1.4 LIN Song Aerospace Structural Dynamcs Research Laboratory College of Astronautcs, Northwestern Polytechncal Unversty, Chna Emal: lsssswc@163.com 2011-07-26 Contents Contents... 1. Introducton...
More informationSetup and Use. Version 3.7 2/1/2014
Verson 3.7 2/1/2014 Setup and Use MaestroSoft, Inc. 1750 112th Avenue NE, Sute A200, Bellevue, WA 98004 425.688.0809 / 800.438.6498 Fax: 425.688.0999 www.maestrosoft.com Contents Text2Bd checklst 3 Preparng
More informationCourse Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms
Course Introducton Course Topcs Exams, abs, Proects A quc loo at a few algorthms 1 Advanced Data Structures and Algorthms Descrpton: We are gong to dscuss algorthm complexty analyss, algorthm desgn technques
More informationDesign and Analysis of Algorithms
Desgn and Analyss of Algorthms Heaps and Heapsort Reference: CLRS Chapter 6 Topcs: Heaps Heapsort Prorty queue Huo Hongwe Recap and overvew The story so far... Inserton sort runnng tme of Θ(n 2 ); sorts
More informationOn Some Entertaining Applications of the Concept of Set in Computer Science Course
On Some Entertanng Applcatons of the Concept of Set n Computer Scence Course Krasmr Yordzhev *, Hrstna Kostadnova ** * Assocate Professor Krasmr Yordzhev, Ph.D., Faculty of Mathematcs and Natural Scences,
More informationWightman. Mobility. Quick Reference Guide THIS SPACE INTENTIONALLY LEFT BLANK
Wghtman Moblty Quck Reference Gude THIS SPACE INTENTIONALLY LEFT BLANK WIGHTMAN MOBILITY BASICS How to Set Up Your Vocemal 1. On your phone s dal screen, press and hold 1 to access your vocemal. If your
More informationThe Go4 Analysis Framework Fit Tutorial v2.2
The Go4 Analyss Framework Ft Tutoral v. J.Adamczewsk, M.Al-Turany, D.Bertn, H.G.Essel, S.Lnev 19 March 003 1 Gettng started... 5 1.1 Introducton... 5 1. Installng... 5 1.3 Theoretcal preface... 6 Go4Ft
More informationCS 534: Computer Vision Model Fitting
CS 534: Computer Vson Model Fttng Sprng 004 Ahmed Elgammal Dept of Computer Scence CS 534 Model Fttng - 1 Outlnes Model fttng s mportant Least-squares fttng Maxmum lkelhood estmaton MAP estmaton Robust
More informationSorting. Sorting. Why Sort? Consistent Ordering
Sortng CSE 6 Data Structures Unt 15 Readng: Sectons.1-. Bubble and Insert sort,.5 Heap sort, Secton..6 Radx sort, Secton.6 Mergesort, Secton. Qucksort, Secton.8 Lower bound Sortng Input an array A of data
More informationLoad Balancing for Hex-Cell Interconnection Network
Int. J. Communcatons, Network and System Scences,,, - Publshed Onlne Aprl n ScRes. http://www.scrp.org/journal/jcns http://dx.do.org/./jcns.. Load Balancng for Hex-Cell Interconnecton Network Saher Manaseer,
More informationActive Contours/Snakes
Actve Contours/Snakes Erkut Erdem Acknowledgement: The sldes are adapted from the sldes prepared by K. Grauman of Unversty of Texas at Austn Fttng: Edges vs. boundares Edges useful sgnal to ndcate occludng
More informationSome Tutorial about the Project. Computer Graphics
Some Tutoral about the Project Lecture 6 Rastersaton, Antalasng, Texture Mappng, I have already covered all the topcs needed to fnsh the 1 st practcal Today, I wll brefly explan how to start workng on
More informationSorting and Algorithm Analysis
Unt 7 Sortng and Algorthm Analyss Computer Scence S-111 Harvard Unversty Davd G. Sullvan, Ph.D. Sortng an Array of Integers 0 1 2 n-2 n-1 arr 15 7 36 40 12 Ground rules: sort the values n ncreasng order
More informationGreedy Technique - Definition
Greedy Technque Greedy Technque - Defnton The greedy method s a general algorthm desgn paradgm, bult on the follong elements: confguratons: dfferent choces, collectons, or values to fnd objectve functon:
More information3D vector computer graphics
3D vector computer graphcs Paolo Varagnolo: freelance engneer Padova Aprl 2016 Prvate Practce ----------------------------------- 1. Introducton Vector 3D model representaton n computer graphcs requres
More informationUniversity of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Conditionals II Lecture 11, Thu Feb 9 2006 based on slides by Kurt Eiselt http://www.cs.ubc.ca/~tmm/courses/cpsc111-06-spr
More informationOutline. Midterm Review. Declaring Variables. Main Variable Data Types. Symbolic Constants. Arithmetic Operators. Midterm Review March 24, 2014
Mdterm Revew March 4, 4 Mdterm Revew Larry Caretto Mechancal Engneerng 9 Numercal Analyss of Engneerng Systems March 4, 4 Outlne VBA and MATLAB codng Varable types Control structures (Loopng and Choce)
More informationETAtouch RESTful Webservices
ETAtouch RESTful Webservces Verson 1.1 November 8, 2012 Contents 1 Introducton 3 2 The resource /user/ap 6 2.1 HTTP GET................................... 6 2.2 HTTP POST..................................
More informationK-means and Hierarchical Clustering
Note to other teachers and users of these sldes. Andrew would be delghted f you found ths source materal useful n gvng your own lectures. Feel free to use these sldes verbatm, or to modfy them to ft your
More informationProblem Definitions and Evaluation Criteria for Computational Expensive Optimization
Problem efntons and Evaluaton Crtera for Computatonal Expensve Optmzaton B. Lu 1, Q. Chen and Q. Zhang 3, J. J. Lang 4, P. N. Suganthan, B. Y. Qu 6 1 epartment of Computng, Glyndwr Unversty, UK Faclty
More informationMachine Learning. Topic 6: Clustering
Machne Learnng Topc 6: lusterng lusterng Groupng data nto (hopefully useful) sets. Thngs on the left Thngs on the rght Applcatons of lusterng Hypothess Generaton lusters mght suggest natural groups. Hypothess
More informationSorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions
Sortng Revew Introducton to Algorthms Qucksort CSE 680 Prof. Roger Crawfs Inserton Sort T(n) = Θ(n 2 ) In-place Merge Sort T(n) = Θ(n lg(n)) Not n-place Selecton Sort (from homework) T(n) = Θ(n 2 ) In-place
More informationLOOP ANALYSIS. The second systematic technique to determine all currents and voltages in a circuit
LOOP ANALYSS The second systematic technique to determine all currents and voltages in a circuit T S DUAL TO NODE ANALYSS - T FRST DETERMNES ALL CURRENTS N A CRCUT AND THEN T USES OHM S LAW TO COMPUTE
More informationChapter 6 Programmng the fnte element method Inow turn to the man subject of ths book: The mplementaton of the fnte element algorthm n computer programs. In order to make my dscusson as straghtforward
More informationParallel matrix-vector multiplication
Appendx A Parallel matrx-vector multplcaton The reduced transton matrx of the three-dmensonal cage model for gel electrophoress, descrbed n secton 3.2, becomes excessvely large for polymer lengths more
More informationAn Optimal Algorithm for Prufer Codes *
J. Software Engneerng & Applcatons, 2009, 2: 111-115 do:10.4236/jsea.2009.22016 Publshed Onlne July 2009 (www.scrp.org/journal/jsea) An Optmal Algorthm for Prufer Codes * Xaodong Wang 1, 2, Le Wang 3,
More informationON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE
Yordzhev K., Kostadnova H. Інформаційні технології в освіті ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE Yordzhev K., Kostadnova H. Some aspects of programmng educaton
More informationOutline. Discriminative classifiers for image recognition. Where in the World? A nearest neighbor recognition example 4/14/2011. CS 376 Lecture 22 1
4/14/011 Outlne Dscrmnatve classfers for mage recognton Wednesday, Aprl 13 Krsten Grauman UT-Austn Last tme: wndow-based generc obect detecton basc ppelne face detecton wth boostng as case study Today:
More informationExercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005
Exercses (Part 4) Introducton to R UCLA/CCPR John Fox, February 2005 1. A challengng problem: Iterated weghted least squares (IWLS) s a standard method of fttng generalzed lnear models to data. As descrbed
More informationMachine Learning: Algorithms and Applications
14/05/1 Machne Learnng: Algorthms and Applcatons Florano Zn Free Unversty of Bozen-Bolzano Faculty of Computer Scence Academc Year 011-01 Lecture 10: 14 May 01 Unsupervsed Learnng cont Sldes courtesy of
More informationDijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance. Decision Sequence.
All-Pars Shortest Paths Gven an n-vertex drected weghted graph, fnd a shortest path from vertex to vertex for each of the n vertex pars (,). Dstra s Sngle Source Algorthm Use Dstra s algorthm n tmes, once
More informationParallel Numerics. 1 Preconditioning & Iterative Solvers (From 2016)
Technsche Unverstät München WSe 6/7 Insttut für Informatk Prof. Dr. Thomas Huckle Dpl.-Math. Benjamn Uekermann Parallel Numercs Exercse : Prevous Exam Questons Precondtonng & Iteratve Solvers (From 6)
More informationLecture 5: Multilayer Perceptrons
Lecture 5: Multlayer Perceptrons Roger Grosse 1 Introducton So far, we ve only talked about lnear models: lnear regresson and lnear bnary classfers. We noted that there are functons that can t be represented
More information! This week: Chapter 6 all ( ) ! Formal parameter: in declaration of class. ! Actual parameter: passed in when method is called
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Reading! This week: Chapter 6 all (6.1-6.4) Static Methods, Conditionals Lecture 10, Tue Feb 7 2006 based on slides
More informationLecture #15 Lecture Notes
Lecture #15 Lecture Notes The ocean water column s very much a 3-D spatal entt and we need to represent that structure n an economcal way to deal wth t n calculatons. We wll dscuss one way to do so, emprcal
More informationFrom zero to Matlab in six weeks
From zero to Matlab n sx weeks Frederk J Smons Adam C. Maloof Prnceton Unversty Explan the bascs I 1. help 2. lookfor 3. type 4. who, whos, whch 7. dary Explan the bascs II 7. plot 8. xlabel, ylabel, ttle
More informationUniversity of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Static Methods, Conditionals Lecture 10, Tue Feb 7 2006 based on slides by Kurt Eiselt http://www.cs.ubc.ca/~tmm/courses/cpsc111-06-spr
More information