Outline. CIS 110: Intro to Computer Programming. What Do Our Programs Look Like? The Scanner Object. CIS 110 (11fa) - University of Pennsylvania 1
|
|
- Erica Ray
- 6 years ago
- Views:
Transcription
1 Outlne CIS 110: Intro to Computer Programmng The Scanner Object Introducng Condtonal Statements Cumulatve Algorthms Lecture 10 Interacton and Condtonals ( 3.3, ) 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 1 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 2 The Scanner Object What Do Our Programs Look Lke? 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 3 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 4 Ths program replcates a drawng of the snkng Ttanc and two survvors n the water. **** ***** ****** ******* ******** ********* ********** *********** *********** \o_ \o/ ~^~^~^~^~^~^~^~^~^~^~^~^~^~^ ~^~^~^~^~^~^~^~^~^~^~^~^~^~^ ~^~^~^~^~^~^~^~^~^~^~^~^~^~^ ~^~^~^~^~^~^~^~^~^~^~^~^~^~^ 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 5 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 6 CIS 110 (11fa) - Unversty of Pennsylvana 1
2 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 7 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 8 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 9 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 10 / \ / \ \./ \./ \/ (o) (o) \/ \/ <> \/ ^ ^ ^ ************ ^ ^ * /\ /\ * ^ ^ * /\ /\ /\ * ^ ^ * /\ /\ /\ * ^ ^ * * ^ ^ * * ^ ^ * * ^ /15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 11 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 12 CIS 110 (11fa) - Unversty of Pennsylvana 2
3 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 13 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 14 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 15 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 16 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 17 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 18 CIS 110 (11fa) - Unversty of Pennsylvana 3
4 Real World Programs Out There Real programs are INTERACTIVE! 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 19 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 20 Introducng the Scanner Class Object that lets you read nput from the user. Scanner s n the "java.utl" package. mport java.utl.*; Creates a new Scanner that reads from some source. Scanner n = new Scanner(System.n); System.out.prntln( "Echo: " + n.nextlne()); "The keyboard" Grabs the next lne of nput from the Scanner. 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 21 Readng Input From The User // Reads n a double double d = n.nextdouble(); // Reads n an nteger nt n = n.nextint(); // Reads n an entre lne Strng lne = n.nextlne(); // Reads a token Strng token = n.next(); 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 22 Tokens Tokens are "chunks" of an nput separated by a delmter (here, whtespace). Ths s a strng "some tokens" n wth t! Tokens: ths, s, a, strng, wth, "some, tokens", n, t! Includes punctuaton (e.g., quotes and bangs). Asde: Packages and mport Classes are bundled nto sets called packages. The mport declaraton says that you wsh to use classes found n a partcular package. // Make avalable all classes n java.utl mport java.utl.*; // Make avalable just the Scanner class mport java.utl.scanner; 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 23 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 24 CIS 110 (11fa) - Unversty of Pennsylvana 4
5 Problem: Makng Decsons Based on User Input Condtonal Statements Scanner n = new Scanner(System.n); double savngs = n.nextdouble(); // If amount s greater than 100, // prnt a congratulatons msg! 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 25 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 26 Introducng Condtonal Statements Syntax of Condtonal Statements "Execute ths block only f savngs s greater than 100." Scanner n = new Scanner(System.n); double savngs = n.nextdouble(); f (savngs > 100) { System.out.prntln("Congratulatons!"); The test or guard f (<test>) { <statement> <statement> <statement> The statements to execute, the body or block 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 27 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 28 Semantcs of Condtonals Else Branches Is the guard true? TRUE Execute the Block Execute statements after condtonal double savngs = n.nextdouble(); f (savngs > 100) { System.out.prntln("Congratuatons!"); else { System.out.prntln("You need more money!"); FALSE "Execute ths block f we don't go nto the frst block" (.e., when savngs s less than or equal to 0). 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 29 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 30 CIS 110 (11fa) - Unversty of Pennsylvana 5
6 Else-f Branches Relatonal Operators double savngs = n.nextdouble(); f (savngs > 100) { System.out.prntln("Congratuatons!"); else f (savngs > 50) { System.out.prntln("That's decent."); else { System.out.prntln("Need more!"); "Else" = f the prevous guard fals, try ths one! 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 31 > /* greater than */ < /* less than */ >= /* greater than or equals */ <= /* less than or equals */ == /* equals */!= /* not-equals*/ // Syntax: <expr> <op> <expr>, e.g., 1!= 2 Only works on prmtve data. We'll dscuss what to do for objects, e.g., Strngs, later. 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 32 Operator Precedence ++, --, +, - // Unary operators *, /, % // Multplcaton operators +, - // Addton operators <, >, <=, >= // Relatonal operators ==,!= // Equalty operators =, +=, -=, *=, /=, %= // Assgnment operators V Lower Precedence 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 33 Mutually exclusve branches f (savngs < 100) { f (savngs < 100) { f (savngs >= 50) { f (savngs == 75) { else f (savngs >= 50) { else f (savngs == 75) { double savngs = 75; else f gves you true mutually exclusve branches. 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 34 Object Equalty Scanner n = new Scanner(System.n); Strng s = n.nextlne(); // Wll never be true. == only works for prmtve types. f (s == "yes") { System.out.prntln("s1 s yes!"); // Need to use the equals method to check equalty for objects. f (s.equals("yes")) { System.out.prntln("s1 s really yes!"); Multple Condtons Scanner n = new Scanner(System.n); Strng name = n.nextlne(); double amount = n.nextdouble(); // Logcal AND: true f both condtons are true f (name.equals("mcscrooge") && amount > 1000) { System.out.prntln("Y U SO RICH!?"); // Logcal OR: true f one of the condtons s true f (name.equals("peter") amount < 10) { System.out.prntln("Y U SO POOR!?"); 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 35 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 36 CIS 110 (11fa) - Unversty of Pennsylvana 6
7 Problem: Interactve Sum Cumulatve Algorthms Can you wrte a program that computes the sum of numbers from 1 to the user's nput? Scanner n = new Scanner(System.n); System.out.prnt("n? "); nt n = n.nextint(); System.out.prntln(); nt sum = 0; for (nt = 0; < n; ++) { sum += ; System.out.prntln( "Sum of 1 to " + 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 37 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 38 Interactve Sum Trace (1) Interactve Sum Trace (2) n 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 39 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 40 Interactve Sum Trace (3) Interactve Sum Trace (4) n n n 5 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 41 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 42 CIS 110 (11fa) - Unversty of Pennsylvana 7
8 Interactve Sum Trace (5) Interactve Sum Trace (6) n n 5 n n 5 sum 0 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 43 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 44 Interactve Sum Trace (7) Interactve Sum Trace (8) 0 0 n n 5 sum 0 n n 5 sum 0 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 45 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 46 Interactve Sum Trace (9) Interactve Sum Trace (10) 1 1 n n 5 sum 0 n n 5 sum 0 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 47 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 48 CIS 110 (11fa) - Unversty of Pennsylvana 8
9 Interactve Sum Trace (11) Interactve Sum Trace (12) 1 2 n n 5 sum 1 n n 5 sum 1 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 49 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 50 Interactve Sum Trace (13) Interactve Sum Trace (13) 2 3 n n 5 sum 3 n n 5 sum 3 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 51 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 52 Interactve Sum Trace (14) Interactve Sum Trace (15) 3 4 n n 5 sum 6 n n 5 sum 6 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 53 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 54 CIS 110 (11fa) - Unversty of Pennsylvana 9
10 Interactve Sum Trace (16) Interactve Sum Trace (17) 4 5 n n 5 sum 10 n n 5 sum 10 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 55 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 56 Interactve Sum Trace (18) n n 5 sum 10 10/15/2011 CIS 110 (11fa) - Unversty of Pennsylvana 57 CIS 110 (11fa) - Unversty of Pennsylvana 10
Outline. 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 informationNews. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example
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
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 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 informationMidterms 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 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 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 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 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 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 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 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 informationCIS 110: Introduction to Computer Programming
CIS 110: Introduction to Computer Programming Lecture 14 Booleans and Program Assertions ( 5.3-5.5) 10/26/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline The boolean primitive type Program assertions
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 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 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 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 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 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 informationKent State University CS 4/ Design and Analysis of Algorithms. Dept. of Math & Computer Science LECT-16. Dynamic Programming
CS 4/560 Desgn and Analyss of Algorthms Kent State Unversty Dept. of Math & Computer Scence LECT-6 Dynamc Programmng 2 Dynamc Programmng Dynamc Programmng, lke the dvde-and-conquer method, solves problems
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 informationLecture 3: Computer Arithmetic: Multiplication and Division
8-447 Lecture 3: Computer Arthmetc: Multplcaton and Dvson James C. Hoe Dept of ECE, CMU January 26, 29 S 9 L3- Announcements: Handout survey due Lab partner?? Read P&H Ch 3 Read IEEE 754-985 Handouts:
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 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 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 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 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 informationSolving two-person zero-sum game by Matlab
Appled Mechancs and Materals Onlne: 2011-02-02 ISSN: 1662-7482, Vols. 50-51, pp 262-265 do:10.4028/www.scentfc.net/amm.50-51.262 2011 Trans Tech Publcatons, Swtzerland Solvng two-person zero-sum game by
More informationThe Codesign Challenge
ECE 4530 Codesgn Challenge Fall 2007 Hardware/Software Codesgn The Codesgn Challenge Objectves In the codesgn challenge, your task s to accelerate a gven software reference mplementaton as fast as possble.
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 informationLLVM passes and Intro to Loop Transformation Frameworks
LLVM passes and Intro to Loop Transformaton Frameworks Announcements Ths class s recorded and wll be n D2L panapto. No quz Monday after sprng break. Wll be dong md-semester class feedback. Today LLVM passes
More informationProblem Set 3 Solutions
Introducton to Algorthms October 4, 2002 Massachusetts Insttute of Technology 6046J/18410J Professors Erk Demane and Shaf Goldwasser Handout 14 Problem Set 3 Solutons (Exercses were not to be turned n,
More informationThe example below contains two doors and no floor level obstacles. Your panel calculator should now look something like this: 2,400
Step 1: A r c h t e c t u r a l H e a t n g o begn wth you must prepare a smple drawng for each room n whch you wsh to nstall our Heat Profle Skrtng Heatng System. You certanly don't need to be Pcasso,
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 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 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 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 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 informationDynamic Programming. Example - multi-stage graph. sink. source. Data Structures &Algorithms II
Dynamc Programmng Example - mult-stage graph 1 source 9 7 3 2 2 3 4 5 7 11 4 11 8 2 2 1 6 7 8 4 6 3 5 6 5 9 10 11 2 4 5 12 snk Data Structures &Algorthms II A labeled, drected graph Vertces can be parttoned
More informationOutline. Third Programming Project Two-Dimensional Arrays. Files You Can Download. Exercise 8 Linear Regression. General Regression
Project 3 Two-densonal arras Ma 9, 6 Thrd Prograng Project Two-Densonal Arras Larr Caretto Coputer Scence 6 Coputng n Engneerng and Scence Ma 9, 6 Outlne Quz three on Thursda for full lab perod See saple
More informationFinal Exam. CSE Section M, Winter p. 1 of 16. Family Name: Given Name(s): Student Number:
Fna Exam CSE 1020 3.0 Secton M, Wnter 2010 p. 1 o 16 Famy Name: Gven Name(s): Student Numer: Gudenes and Instructons: 1. Ths s a 90-mnute exam. You can use the textook, ut no eectronc ads such as cacuators,
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 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 informationIntroduction. Leslie Lamports Time, Clocks & the Ordering of Events in a Distributed System. Overview. Introduction Concepts: Time
Lesle Laports e, locks & the Orderng of Events n a Dstrbuted Syste Joseph Sprng Departent of oputer Scence Dstrbuted Systes and Securty Overvew Introducton he artal Orderng Logcal locks Orderng the Events
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 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 informationModel Clipping Triangle Strips and Quad Meshes.
Model Clppng Trangle Strps and Quad Meshes. Patrc-Glles Mallot Sun Mcrosystems, Inc. 2550 Garca Avenue, Mountan Vew, CA 94043 Abstract Ths paper descrbes an orgnal software mplementaton of 3D homogeneous
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 informationsuch that is accepted of states in , where Finite Automata Lecture 2-1: Regular Languages be an FA. A string is the transition function,
* Lecture - Regular Languages S Lecture - Fnte Automata where A fnte automaton s a -tuple s a fnte set called the states s a fnte set called the alphabet s the transton functon s the ntal state s the set
More informationMATHEMATICS FORM ONE SCHEME OF WORK 2004
MATHEMATICS FORM ONE SCHEME OF WORK 2004 WEEK TOPICS/SUBTOPICS LEARNING OBJECTIVES LEARNING OUTCOMES VALUES CREATIVE & CRITICAL THINKING 1 WHOLE NUMBER Students wll be able to: GENERICS 1 1.1 Concept of
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 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 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 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 informationan assocated logc allows the proof of safety and lveness propertes. The Unty model nvolves on the one hand a programmng language and, on the other han
UNITY as a Tool for Desgn and Valdaton of a Data Replcaton System Phlppe Quennec Gerard Padou CENA IRIT-ENSEEIHT y Nnth Internatonal Conference on Systems Engneerng Unversty of Nevada, Las Vegas { 14-16
More information6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour
6.854 Advanced Algorthms Petar Maymounkov Problem Set 11 (November 23, 2005) Wth: Benjamn Rossman, Oren Wemann, and Pouya Kheradpour Problem 1. We reduce vertex cover to MAX-SAT wth weghts, such that the
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 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 informationImproving Low Density Parity Check Codes Over the Erasure Channel. The Nelder Mead Downhill Simplex Method. Scott Stransky
Improvng Low Densty Party Check Codes Over the Erasure Channel The Nelder Mead Downhll Smplex Method Scott Stransky Programmng n conjuncton wth: Bors Cukalovc 18.413 Fnal Project Sprng 2004 Page 1 Abstract
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 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 informationConditional Speculative Decimal Addition*
Condtonal Speculatve Decmal Addton Alvaro Vazquez and Elsardo Antelo Dep. of Electronc and Computer Engneerng Unv. of Santago de Compostela, Span Ths work was supported n part by Xunta de Galca under grant
More informationConcurrent models of computation for embedded software
Concurrent models of computaton for embedded software and hardware! Researcher overvew what t looks lke semantcs what t means and how t relates desgnng an actor language actor propertes and how to represent
More information2D Raster Graphics. Integer grid Sequential (left-right, top-down) scan. Computer Graphics
2D Graphcs 2D Raster Graphcs Integer grd Sequental (left-rght, top-down scan j Lne drawng A ver mportant operaton used frequentl, block dagrams, bar charts, engneerng drawng, archtecture plans, etc. curves
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 informationPrivate Information Retrieval (PIR)
2 Levente Buttyán Problem formulaton Alce wants to obtan nformaton from a database, but she does not want the database to learn whch nformaton she wanted e.g., Alce s an nvestor queryng a stock-market
More informationOntology Generator from Relational Database Based on Jena
Computer and Informaton Scence Vol. 3, No. 2; May 2010 Ontology Generator from Relatonal Database Based on Jena Shufeng Zhou (Correspondng author) College of Mathematcs Scence, Laocheng Unversty No.34
More informationIntroduction to Geometrical Optics - a 2D ray tracing Excel model for spherical mirrors - Part 2
Introducton to Geometrcal Optcs - a D ra tracng Ecel model for sphercal mrrors - Part b George ungu - Ths s a tutoral eplanng the creaton of an eact D ra tracng model for both sphercal concave and sphercal
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 informationAn Entropy-Based Approach to Integrated Information Needs Assessment
Dstrbuton Statement A: Approved for publc release; dstrbuton s unlmted. An Entropy-Based Approach to ntegrated nformaton Needs Assessment June 8, 2004 Wllam J. Farrell Lockheed Martn Advanced Technology
More informationLECTURE 7. Lex and Intro to Parsing
LECTURE 7 Lex and Intro to Parsing LEX Last lecture, we learned a little bit about how we can take our regular expressions (which specify our valid tokens) and create real programs that can recognize them.
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT 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 informationAn Approach to Real-Time Recognition of Chinese Handwritten Sentences
An Approach to Real-Tme Recognton of Chnese Handwrtten Sentences Da-Han Wang, Cheng-Ln Lu Natonal Laboratory of Pattern Recognton, Insttute of Automaton of Chnese Academy of Scences, Bejng 100190, P.R.
More informationAn Approach in Coloring Semi-Regular Tilings on the Hyperbolic Plane
An Approach n Colorng Sem-Regular Tlngs on the Hyperbolc Plane Ma Louse Antonette N De Las Peñas, mlp@mathscmathadmueduph Glenn R Lago, glago@yahoocom Math Department, Ateneo de Manla Unversty, Loyola
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 informationCompiling Process Networks to Interaction Nets
Complng Process Networks to Interacton Nets Ian Macke LIX, CNRS UMR 7161, École Polytechnque, 91128 Palaseau Cede, France Kahn process networks are a model of computaton based on a collecton of sequental,
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 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 informationChapter 2 Introduction to Query Optimization
4 Chapter 2 ntroducton to Query Optmzaton 2.1 Query Optmzaton Outlne n ths secton, we wll cover the followng topcs:. 1) Query Processor Components tokenzer, parser, access planner, optmzer, buffer manager
More informationDijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance
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 (,). Dkstra s Sngle Source Algorthm Use Dkstra s algorthm n tmes,
More informationIteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times
Iteration: Intro Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times 2. Posttest Condition follows body Iterates 1+ times 1 Iteration: While Loops Pretest loop Most general loop construct
More informationTransaction-Consistent Global Checkpoints in a Distributed Database System
Proceedngs of the World Congress on Engneerng 2008 Vol I Transacton-Consstent Global Checkponts n a Dstrbuted Database System Jang Wu, D. Manvannan and Bhavan Thurasngham Abstract Checkpontng and rollback
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 informationAADL : about scheduling analysis
AADL : about schedulng analyss Schedulng analyss, what s t? Embedded real-tme crtcal systems have temporal constrants to meet (e.g. deadlne). Many systems are bult wth operatng systems provdng multtaskng
More informationT3 (IP) Classic connected to Integral 5
IP Telephony Contact Centers Moblty Servces T3 (IP) Classc connected to Integral 5 Benutzerhandbuch User s gude Manual de usuaro Manuel utlsateur Manuale d uso Gebrukersdocumentate Contents Contents...
More informationBiostatistics 615/815
The E-M Algorthm Bostatstcs 615/815 Lecture 17 Last Lecture: The Smplex Method General method for optmzaton Makes few assumptons about functon Crawls towards mnmum Some recommendatons Multple startng ponts
More informationFlow of Control. Flow of control The order in which statements are executed. Transfer of control
1 Programming in C Flow of Control Flow of control The order in which statements are executed Transfer of control When the next statement executed is not the next one in sequence 2 Flow of Control Control
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 informationV2 2/4/ Ch Programming in C. Flow of Control. Flow of Control. Flow of control The order in which statements are executed
Programming in C 1 Flow of Control Flow of control The order in which statements are executed Transfer of control When the next statement executed is not the next one in sequence 2 Flow of Control Control
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 informationChecking Multiple Conditions
Checking Multiple Conditions Conditional code often relies on a value being between two other values Consider these conditions: Free shipping for orders over $25 10 items or less Children ages 3 to 11
More informationQuicksort. Part 1: Understanding Quicksort
Qucksort Part 1: Understandng Qucksort https://www.youtube.com/watch?v=ywwby6j5gz8 Qucksort A practcal algorthm The hdden constants are small (hdden by Bg-O) Succnct algorthm The runnng tme = O(n lg n)
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 informationInternet Traffic Managers
Internet Traffc Managers Ibrahm Matta matta@cs.bu.edu www.cs.bu.edu/faculty/matta Computer Scence Department Boston Unversty Boston, MA 225 Jont work wth members of the WING group: Azer Bestavros, John
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 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 informationComposition of UML Described Refactoring Rules *
Composton of UML Descrbed Refactorng Rules * Slavsa Markovc Swss Federal Insttute of Technology Department of Computer Scence Software Engneerng Laboratory 05 Lausanne-EPFL Swtzerland e-mal: Slavsa.Markovc@epfl.ch
More informationMath Homotopy Theory Additional notes
Math 527 - Homotopy Theory Addtonal notes Martn Frankland February 4, 2013 The category Top s not Cartesan closed. problem. In these notes, we explan how to remedy that 1 Compactly generated spaces Ths
More informationRelated-Mode Attacks on CTR Encryption Mode
Internatonal Journal of Network Securty, Vol.4, No.3, PP.282 287, May 2007 282 Related-Mode Attacks on CTR Encrypton Mode Dayn Wang, Dongda Ln, and Wenlng Wu (Correspondng author: Dayn Wang) Key Laboratory
More information