Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/http://creativecommons.org/licenses/by-nc-

Slides:



Advertisements
Similar presentations
One Dimensional Arrays
Advertisements

Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Lists Introduction to Computing Science and Programming I.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Topic 9 – Introduction To Arrays. CISC105 – Topic 9 Introduction to Data Structures Thus far, we have seen “simple” data types. These refers to a single.
Workshop on Peer Instruction: Making Good Clicker Questions Beth Simon Computer Science and Engineering University of California, San Diego Credits: Sara.
Pointers Pointer - A pointer is a derived data type; that is it is a data type built from one of the standard types. Its value is any of the addresses.
1 Lecture Today’s topic Arrays Reading for this Lecture: –Chaper 11.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
R-1 University of Washington Computer Programming I Lecture 17: Multidimensional Arrays © 2000 UW CSE.
Basic Building Blocks of Programming. Variables and Assignment Think of a variable as an empty container Assignment symbol (=) means putting a value into.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
EGR 2261 Unit 8 One-dimensional Arrays  Read Malik, pages in Chapter 8.  Homework #8 and Lab #8 due next week.  Quiz next week.
Arrays The concept of arrays Using arrays Arrays as arguments Processing an arrays data Multidimensional arrays Sorting data in an array Searching with.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
COMPUTER PROGRAMMING. Functions What is a function? A function is a group of statements that is executed when it is called from some point of the program.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSC 107 – Programming For Science. Today’s Goal  Discuss how to hand data to functions  Review loopholes in variables & scoping rules  Ways to get.
CSC 107 – Programming For Science. The Week’s Goal.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops Barb Ericson Georgia Institute of Technology August 2005.
TOPIC 6 MODIFYING PICTURES USING LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
read and learn from example loop programs develop modular program
1 CMSC 202 Pointers Dynamic Memory Allocation. 2 A simple variable A variable is drawn as a labeled box int x; X :
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CPSC1301 Computer Science 1 Chapter 4 Manipulating Pictures, Arrays, and Loops part 5.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Building java programs, chapter 3 Parameters, Methods and Objects.
Lecture 5 functions 1 © by Pearson Education, Inc. All Rights Reserved.
Structuring Data: Arrays ANSI-C. Representing multiple homogenous data Problem: Input: Desired output:
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
CSE8A Lecture 5 TODO: –FINISH PSA2 WITH YOUR PARTNER! Read next class: Section 5.1. PLAY WITH CODE! –Get stuck, then figure out how to get unstuck – it’s.
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
04-ManipulatingPictures-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology June 2008.
1 ENERGY 211 / CME 211 Lecture 4 September 29, 2008.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
1 CMSC 202 Pointers Dynamic Memory Allocation. 2 A simple variable A variable is drawn as a labeled box int x; X :
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Windows Programming Lecture 03. Pointers and Arrays.
CSC Programming for Science Lecture 5: Actual Programming.
Creative Commons Attribution Non-Commercial Share Alike License
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops
Structure of a C Program
Manipulating Pictures, Arrays, and Loops part 5
Unit-1 Introduction to Java
CSE 8A Lecture 6 Reading for next class:
Lecture 18 Arrays and Pointer Arithmetic
Creative Commons Attribution Non-Commercial Share Alike License
CS 200 Primitives and Expressions
Manipulating Pictures, Arrays, and Loops
Creative Commons Attribution Non-Commercial Share Alike License
Creative Commons Attribution Non-Commercial Share Alike License
Building Java Programs
Building Java Programs
Presentation transcript:

Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/ sa/3.0/ Original Developer: Beth Simon, 2009

CSE8A Lecture 7 Read next class: read pg , –take the online reading quiz (there’s NEW questions). Discussion Section! 3pm or 4pm

By the end of today’s class you should be able to… LG13: Read and understand a while loop for modifying a Picture, including being able to draw a memory model of this code LG14: Describe the single array representation of pixels in Picture.java LG16: Find bugs in code including: a common “empty loop” bug, using the “how many times does this statement get executed” analysis technique. LG17: Argue about the best location of a print statement to debug a problem with a loop. LG18: Apply knowledge of how people pass racketballs to swap values of variables LG19: Read and trace execution of a code with a for loop (using a single array of pixels).

Rules of Memory Model Drawing Two sections of memory (separate them somehow): –Simple memory: primitive type variable “boxes” with actual data in them Class/object variable “boxes” have an arrow in them to complex memory –Complex memory: class/object type ACTUAL DATA is stored here Declaration ; –Write down the name in the correct memory space –Class/object types actually have an empty box (will have arrow later) Instantiation/Assignment –Draw box (or multi-boxes if array) and fill in values Ok, we’re not writing in all the pixel values, but maybe some. Execution (sequential or loop) –If an assignment is made, change the value in the box on the left side of the assignment –If you need to evaluate an expression, read the values in the boxes to help.

Play computer: draw a model of memory* Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; int index = 0; while (index < pixelArray.length) { value = pixelArray[index].getRed(); value = (int) (value * 0.5); pixelArray[index].setRed(value); } * This is something you WILL be asked to do on an exam/quiz.

What does this code do?* A.Removes all red from the picture B.Changes ½ of the red pixels to not be red C.Reduces the red component of ½ of the pixels D.Reduces the red component of each pixel to ½ of its original value E.Sets the red component of each pixel to 0.5 Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; int index = 0; while (index < pixelArray.length) { value = pixelArray[index].getRed(); value = (int) (value * 0.5); pixelArray[index].setRed(value); } * This is something you WILL be asked to do on an exam/quiz.

What pixels does this code modify? Pixel[] pixelArray = this.getPixels(); int value = 0; int index = 0; while (index < pixelArray.length/4) { value = pixelArray[index].getRed(); value = (int) (value * 0.5); pixelArray[index].setRed(value); } 1)Solo: (60 sec) 2)Discuss: (2min) 3)Group: (30 sec)

DEBUGGING: How many times is each set of code executed? Pixel[] pixelArray = this.getPixels(); int value = 0; Pixel p = null; int index = 0; while (index < pixelArray.length); { value = pixelArray[index].getRed(); value = (int) (value * 0.5); pixelArray[index].setRed(value); index = index + 1; } 1)Solo: (30 sec) 2)Discuss: (1min) 3)Group: (30 sec)