CS305j Introduction to Computing Two Dimensional Arrays 1 Topic 22 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right.

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays.
Advertisements

Arrays.
1 CS 162 Introduction to Computer Science Chapter 7 Matrix Manipulation Herbert G. Mayer, PSU Status 9/21/2014.
Programming project #2 1 CS502 Spring 2006 Programming Project #2 CS-502 Operating Systems Spring 2006.
Chapter 7 Multidimensional Arrays. Defining a two dimensional array elementType[][] arrayName; // Java pro elementType arrayName[][]; // C++ alternate.
Game of Life Rules and Games Linh Tran ECE 573. What is Life? Life is just one example of a cellular automaton, which is any system in which rules are.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Introduction to Parallel Processing Final Project SHARKS & FISH Presented by: Idan Hammer Elad Wallach Elad Wallach.
1 The Game of Life Supplement 2. 2 Background The Game of Life was devised by the British mathematician John Horton Conway in More sophisticated.
Maths for Computer Graphics
Arrays. Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left
Slides prepared by Rose Williams, Binghamton University Chapter 6 Arrays.
CELLULAR AUTOMATON Presented by Rajini Singh.
Arrays  Writing a program that uses a large amount of information.  Such as a list of 100 elements.  It is not practical to declare.
1 2-D Arrays Overview l Why do we need Multi-dimensional array l 2-D array declaration l Accessing elements of a 2-D array l Declaration using Initializer.
Multidimensional Arrays in Java Vidhu S. Kapadia.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 8 Multidimensional.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
Conway’s Game of Life Andrew Williams
Chapter 9 Introduction to Arrays
Project 1CS-4513, D-Term Programming Project #1 Concurrent Game of Life Due Friday, March 20.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
Parallelization: Conway’s Game of Life. Cellular automata: Important for science Biology – Mapping brain tumor growth Ecology – Interactions of species.
Introduction Computational Challenges Serial Solutions Distributed Memory Solution Shared Memory Solution Parallel Analysis Conclusion Introduction: 
Multi-Dimensional Arrays in Java "If debugging is the process of removing software bugs, then programming must be the process of putting them in." -- Edsger.
Java Unit 9: Arrays Declaring and Processing Arrays.
One Dimensional Arrays. Declaring references to array objects How would you declare a variable somearray that is an array of ints? int[] somearray;
STAT115 STAT225 BIST512 BIO298 - Intro to Computational Biology Python Tutorial II Monty Python, Game of Life and Sequence Alignment Feb 1, 2011 Daniel.
More Accurate Rate Estimation CS 170: Computing for the Sciences and Mathematics.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
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.
Cellular Automata. The Game The Game of Life is not your typical computer game. It is a 'cellular automation', and was invented by the Cambridge mathematician.
Parallel Programming 0024 Spring Semester 2010 May 6, 2010.
The Game of Life Erik Amelia Amy. What is the “Game of Life?” The “Game of Life” (often referred to as Life) is not your typical game. There are no actual.
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}};
Lecture Set 9 Arrays, Collections and Repetition Part C - Random Numbers Rectangular and Jagged arrays.
Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 8 Multidimensional Arrays.
Copyright © Curt Hill Multiple Dimension Arrays Extending Java Arrays.
4.4 Identify and Inverse Matrices Algebra 2. Learning Target I can find and use inverse matrix.
ITI 1120 Lab #9 Slides by: Diana Inkpen and Alan Williams.
A Variation on Conway’s Game of Life Winston Lee EPS 109.
Cellular Automata Introduction  Cellular Automata originally devised in the late 1940s by Stan Ulam (a mathematician) and John von Neumann.  Originally.
David Squeri CELLULAR AUTOMATON. A cellular automaton is an array of cells that switch on or off depending on whether other cells are on or off. “Rules”
Ionut Trestian Northwestern University
Week 9 - Monday.  What did we talk about last time?  Method practice  Lab 8.
Conway’s Game of Life Jess Barak Game Theory. History Invented by John Conway in 1970 Wanted to simplify problem from 1940s presented by John von Neumann.
Week 9 - Wednesday.  What did we talk about last time?  2D arrays  Queen attacking pawn example  Started Game of Life.
Arrays.
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.
CS305j Introduction to Computing More Conditional Execution 1 Topic 13 More Conditional Execution " Great dancers are not great because of their technique;
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
Two-Dimensional Data Class of 5 students Each student has 3 test scores Store this information in a two- dimensional array First dimension: which student.
CS305j Introduction to Computing Parameters Case Study 1 Topic 10 Parameters Case Study " Thinking like a computer scientist means more than being able.
Practical Session 9 Computer Architecture and Assembly Language.
Lecture 8: 2D Arrays and Nested Loops
Two-Dimensional Arrays
Two-Dimensional Arrays
Topic Dimensional Arrays
Two-dimensional arrays
Two-Dimensional Arrays
Topic 26 Two Dimensional Arrays
Introduction To Programming Information Technology , 1’st Semester
Multidimensional Arrays
Programming Assignment #6
Multidimensional Arrays
Multi-Dimensional Arrays
Sample Question Styles
Presentation transcript:

CS305j Introduction to Computing Two Dimensional Arrays 1 Topic 22 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable techniques to solve it." -Alfred Aho and Jeffery Ullman Based on slides for Building Java Programs by Reges/Stepp, found at

CS305j Introduction to Computing Two Dimensional Arrays 2 2D Arrays in Java  Arrays with multiple dimensions may be declared and used int[][] mat = new int[3][4];  the number of pairs of square brackets indicates the dimension of the array.  by convention, in a 2D array the first number indicates the row and the second the column

CS305j Introduction to Computing Two Dimensional Arrays column row This is our abstract picture of the 2D array and treating it this way is fine. mat[2][1] = 12;

CS305j Introduction to Computing Two Dimensional Arrays 4 What is What? int[][] mat = new int[10][12]; // mat is a reference to the whole 2d array // mat[0] or mat[r] are references to a single row // mat[0][1] or mat[r][c] are references to // single elements // no way to refer to a single column

CS305j Introduction to Computing Two Dimensional Arrays 5 2D Array Problems  Write a method to mind the max value in a 2d array of ints  Write a method to print out the elements of a 2d array of ints in row order. –row 0, then row 1, then row 2...  Write a method to print out the elements of a 2d array of ints in column order –column 0, then column 1, then column 2...

CS305j Introduction to Computing Two Dimensional Arrays 6 Use of Two Dimensional Arrays  2D arrays are often used when I need a table of data or want to represent things that have 2 dimensions.  For instance an area of a simulation

CS305j Introduction to Computing Two Dimensional Arrays 7 Example of using a 2D array  Conway's game of life –a cellular automaton designed by John Conway, a mathematician –not really a game –a simulation –takes place on a 2d grid –each element of the grid is occupied or empty

CS305j Introduction to Computing Two Dimensional Arrays 8 Generation *. *. * *. * * * *.. * *. *. * * *. * * indicates occupied,. indicates empty

CS305j Introduction to Computing Two Dimensional Arrays 9 Or

CS305j Introduction to Computing Two Dimensional Arrays 10 Generation *. *. *..... *. *. *.. * indicates occupied,. indicates empty

CS305j Introduction to Computing Two Dimensional Arrays 11 Or, Generation

CS305j Introduction to Computing Two Dimensional Arrays 12 Rules of the Game  If a cell is occupied in this generation. –it survives if it has 2 or 3 neighbors in this generation –it dies if it has 0 or 1 neighbors in this generation –it dies if it has 4 or more neighbors in this generation  If a cell is unoccupied in this generation. –there is a birth if it has exactly 3 neighboring cells that are occupied in this generation  Neighboring cells are up, down, left, right, and diagonal. In general a cell has 8 neighboring cells

CS305j Introduction to Computing Two Dimensional Arrays 13 Simulation 

CS305j Introduction to Computing Two Dimensional Arrays 14 Problem  Implement a program to run the game automatically.