Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems

Slides:



Advertisements
Similar presentations
EXAMPLES (Arrays). Example Many engineering and scientific applications represent data as a 2-dimensional grid of values; say brightness of pixels in.
Advertisements

How to View User Counts on Sharp Copiers with Account Controls Enabled.
Lecture 19: Parallel Algorithms
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Programming Project 1 Truth Table Lecture 03, file P1 Due January.
1 CS 162 Introduction to Computer Science Chapter 7 Matrix Manipulation Herbert G. Mayer, PSU Status 9/21/2014.
1 Convert this problem into our standard form: Minimize 3 x x 2 – 6 x 3 subject to 1 x x 2 – 3 x 3 ≥ x x 2 – 6 x 3 ≤ 5 7 x 1.
Jeopardy Objects Navigation Buttons True/False Parts of a Report Vocabulary Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final.
Stacks CS 3358 – Data Structures. What is a stack? It is an ordered group of homogeneous items of elements. Elements are added to and removed from the.
CS 177 Recitation Week 8 – Methods. Questions? Announcements  Project 3 milestone due next Thursday 10/22 9pm  Turn in with: turnin –c cs177=xxxx –p.
1 Lecture 25: Parallel Algorithms II Topics: matrix, graph, and sort algorithms Tuesday presentations:  Each group: 10 minutes  Describe the problem,
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 8 Multidimensional.
CS305j Introduction to Computing Two Dimensional Arrays 1 Topic 22 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right.
Mathematics Long Multiplication.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Website design Feng Zhao College of Educatioin California State University, Northridge.
How to Download and Install a Sharp Print Driver on a Mac.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
Matrices Square is Good! Copyright © 2014 Curt Hill.
Web Technologies Website Development Trade & Industrial Education
1.00 Lecture 22 Systems of Linear Equations. 3x 0 + x 1 -2x 2 =5 2x 0 + 4x 1 + 3x 2 = 35 x 0 -3x 1 = x x 1 = x 2 -5 A x =b 3 x.
CS 5 Today HW 9 (lab + 2 probs) due Sunday, 11/8 at midnight Dizzying arrays of possibilities… John Conway Carl Gauss This week’s credits: Exam 2 on Mon.,Tue.
HOW TO BUILD YOUR CULINARY ARTS PORTFOLIO. Adding a New Slide/ Duplicating a Slide Go to the slide menu on the left side of the screen Right click to.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
Columns run horizontally in tables and rows run from left to right.
CS 3870/CS 5870 Web Protocols, Technologies and Applications.
Problem Solving using the Java Programming Language May 2010 Mok Heng Ngee Day 5: Arrays.
Homework 11 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/14 Mon., 11/15 Problems
Two Dimensional Arrays
Homework 3 Due ( MT sections ) ( WTh sections ) at midnight Sun., 9/21 Mon., 9/22 Problems
The Game of Life A simulation of "life". From simple rules, complex behavior arises Rules –A cell that is alive and has fewer than two live neighbors dies.
Topic 26 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable.
EECS 110: Lec 12: Mutable Data Aleksandar Kuzmanovic Northwestern University
1 Data Structures CSCI 132, Spring 2014 Lecture 4 Implementing Life.
Review Recursion Call Stack. Two-dimensional Arrays Visualized as a grid int[][] grays = {{0, 20, 40}, {60, 80, 100}, {120, 140, 160}, {180, 200, 220}};
This week in CS 5 HW 9 (2 problems) M/T sections W/Th sections due Sunday, 11/4 at midnight due Monday, 11/5 at midnight Recitation for HW9 -- Friday 11/2.
Microsoft Access 2007 Tutorial (Part II) CIS*1000*DE.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 8 Multidimensional Arrays.
PRINTING & PAGE BREAKS 1 Nolan Tomboulian Tomboulian.Wikispaces.com.
Printing a Presentation Objective: Print a PowerPoint Presentation Objective: Print a PowerPoint Presentation Given: Handout, Lecture, previous notes,
Learning How to Make a PowerPoint Presentation A tutorial for novice users.
© MECHAN 2009 All right reserved. MecGrid W I Z A R D How to be a magician for your MecGrid. Data Visual with W I Z A R D.
CS543: WEB APPLICATION PROGRAMMING Lab 1: HTML tags & SW installation Computer Science Department.
Homework 8 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/28 Mon., 10/29 Problems Reading is under week 7, however.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
Ionut Trestian Northwestern University
Week 9 - Monday.  What did we talk about last time?  Method practice  Lab 8.
CS Class 15 Today  More practice with arrays  Introduction to Multi-dimensional arrays Announcements  Programming project #4 due 10/23 by midnight.
Week 9 - Wednesday.  What did we talk about last time?  2D arrays  Queen attacking pawn example  Started Game of Life.
EECS 110: Lec 12: Mutable Data Aleksandar Kuzmanovic Northwestern University
Two Dimensional Arrays. Students will be able to: code algorithms to solve two- dimensional array problems. use 2-D arrays in programs. pass two-use 2-D.
Midterm Review Tami Meredith. Primitive Data Types byte, short, int, long Values without a decimal point,..., -1, 0, 1, 2,... float, double Values with.
CS 221 – May 22 Timing (sections 2.6 and 3.6) Speedup Amdahl’s law – What happens if you can’t parallelize everything Complexity Commands to put in your.
Homework 10 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/10 Mon., 11/11 Problems
Practical Session 9 Computer Architecture and Assembly Language.
EECS 110: Lec 12: Mutable Data
1.5 Matricies.
Week 9 - Monday CS 121.
How to Create Tables & Charts/Graphs in Excel
HMC’s Galileo Auditorium Some of Cope’s generated MP3s:
Topic 26 Two Dimensional Arrays
Ionut Trestian Northwestern University
2D Array and Matrix.
CS288 Lab Exercise 2.
CS Software Studio Assignment 1
Year 6 Mathematics Resources
Northwestern University
EECS 110: Lec 12: Mutable Data
2D Array and Matrix Application: Game of Life
Presentation transcript:

Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems Tutors available Fri Afternoon 1-4pm (Parsons & LAC) Sat Afternoon 1-4pm (Parsons & LAC) Sun Afternoon 1-4pm (Parsons & LAC} Sun Evening 7-12pm (Parsons & LAC) Mon Evening 7-12pm (Parsons & LAC) names and hours on syllabus on CS 5 home page: fall/cs5/

Problem 2 -- Life Evolutionary rules Everything depends on one’s eight neighbors black cells are alive white cells are empty Exactly 3 neighbors give birth to a new, live cell! Exactly 2 or 3 neighbors keep an existing cell alive Any other number of neighbors kill the central cell (or keep it dead)

public void update(int[][] last, int[][] next) For each generation… 0 represents an empty cell 1 represents a living cell outermost edge should always be empty (even if there are 3 neighbors) compute all cells based on their previous neighbors before updating any of them Problem 2 -- Life black cells are alive white cells are empty

Problem 2 -- Life // implementing the evolutionary rules r,c last r,c next

public void update(int[][] last, int[][] next) { Problem 2 -- Life // outline of code } g.lifeUpdate(next); //draw new state!

Problem 2 -- Life Details on getting and using the code... Download from CS 5 home page (first page, top link). Be sure to unzip resulting file. Using project: go into NewGrid folder and open NewGrid.mcp project file. The CS5App.java file contains an empty update method You can use any colors to actually show the live and empty cells (default: black is alive; white is dead). Testing is easiest on a small (e.g. 10x10) grid. Click on squares to toggle their state (helpful in debugging).

Problem 1 (0) Change the values in the array (1) Print the array (2) Multiply an array row (3) Add one row to another (4) Add a multiple of one row to another (5) Solve! (9) Quit Which choice would you like? Menu Overall structure of main : similar to HW8’s problem 1 Initial Setup Get the number of rows and columns Get initial values from the user into the array. Create an array of the appropriate number of elements ( doubles ). Methods printMenu enterArray printArray multRow addR1ToR2 addMR1ToR2 solve

2d arrays -- naming things double[][] arr; arr = new double[nRows][nCols]; double

Multiplying rows public static void multRow(double[][] arr, int r, double m) { } BeforeAfter

Gaussian Elimination Goal: get 1s along the diagonal get 0s elsewhere on the left Algorithm: go column-by-column how many columns? how many rows in each column? Setup: arr Will any array work?

Solve multiply Row 0 by add 3 times Row 0 to Row 1 add -1 times Row 0 to Row 2 repeat for column 2 and column 3 and so on...

Solve public static void solve(double[][] arr)

//for debugging.... public static void userPrompt() { H.out.print("enter any text to continue..."); String line = H.in.nextWord(); } public static void someFunction(int [][] arr) { boolean debug = true; for(int i = 0; i < arr.length; i++) { double blah = 1/arr[i][i]; multRow(arr,i,blah); if(debug) { H.out.print(“blah "); H.out.print(blah); H.out.println(" "); printArray(arr); userPrompt(); } //do some more stuff } //some more stuff… } Debugging Aids…