Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.

Slides:



Advertisements
Similar presentations
CSC 107 – Programming For Science. Todays Goal After today, should know why we use loops How to use while & do / while loops in code Know & explain when.
Advertisements

Lists Chapter 4 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
Hash Tables and Sets Lecture 3. Sets A set is simply a collection of elements Unlike lists, elements are not ordered Very abstract, general concept with.
Student Manager Catalog Builder An ACEware Webinar.
Lecture 6 b Last time: array declaration and instantiationarray declaration and instantiation array referencearray reference bounds checkingbounds checking.
Modified from notes by Saeid Nooshabadi COMP3221: Microprocessors and Embedded Systems Lecture 25: Cache - I Lecturer:
CSC Programming for Science Lecture 30: Pointers.
Chapter 9 Introduction to Arrays
CS0007: Introduction to Computer Programming Introduction to Arrays.
More Arrays Length, constants, and arrays of arrays By Greg Butler.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
CSC 212 – Data Structures Lecture 3: Fields, Methods, & Constructors.
Question of the Day  What card(s) must you flip to verify the following statement: Cards with a vowel on one side, have an even number on the other side.
CHP - 9 File Structures. INTRODUCTION In some of the previous chapters, we have discussed representations of and operations on data structures. These.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
Problem of the Day  What is the smallest positive integer that cannot be defined in less than twenty-five syllables?
CSC 213 – Large Scale Programming. Today’s Goal  Consider what will be important when searching  Why search in first place? What is its purpose?  What.
Question of the Day  What card(s) must you flip to verify the following statement: Cards with a vowel on one side, have an even number on the other side.
GCSE Computing Memory Powerpoint Templates.
Mason Vail.  A data type definition – “blueprint for objects”  Includes properties and/or methods ◦ “instance” data / methods – specific to one object.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage.
File Processing - Indexing MVNC1 Indexing Jim Skon.
CSC Intro. to Computing Lecture 13: PALGO. Announcements Midterm is in one week  Time to start reviewing  We will do more review in class Tuesday.
CSC 107 – Programming For Science. Today’s Goal Variables  Variable  Variable name location to store data  Only for humans; 0 x 7E8A2410 harder to.
English Conundrum s  In English, add “s” to end of word to make plural s  But for 1 special word, adding an “s” at the end:  Makes word go from plural.
CSE 232: C++ pointers, arrays, and references Overview of References and Pointers Often need to refer to another object –Without making a copy of the object.
ARRAYS Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall
IT253: Computer Organization
Problem of the Day  Why are manhole covers round?
Lecture 30 Read Only Memory (ROM)
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
1.NET Web Forms Business Forms © 2002 by Jerry Post.
Problem of the Day  Why are manhole covers round?
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
CSC 107 – Programming For Science. Today’s Goal  Discuss how to hand data to functions  Review loopholes in variables & scoping rules  Ways to get.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
CSC 213 Lecture 10: BTrees. Announcements You should not need to do more than the lab exercise states  If only says add a CharRange, you should not need.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
LECTURE 34: MAPS & HASH CSC 212 – Data Structures.
CSC 212 – Data Structures Lecture 37: Course Review.
CSC 107 – Programming For Science. Today’s Goal  Become familiar with simple arrays  Declaring an array variable  Assigning data to array entries 
1 CS 177 Week 12 Recitation Slides Running Time and Performance.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
Data Structures Types of Data Structure Data Structure Operations Examples Choosing Data Structures Data Structures in Alice.
CSC 212 – Data Structures Lecture 2: Primitives, References, & Classes.
CSC 107 – Programming For Science. Today’s Goal  Learn what structures are & how they are used  Why we need & why would use a structure  What fields.
Question of the Day  How can you change the position of 1 toothpick and leave the giraffe in exactly the same form, but possibly mirror-imaged or oriented.
Memory Management in Java Computer Science 3 Gerb Objective: Understand references to composite types in Java.
Java Software Solutions Lewis and Loftus Chapter 6 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Objects for Organizing Data.
CSC Programming for Science Lecture 34: Dynamic Pointers.
CSC Intro. to Computing Lecture 11: Spreadsheets.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
CSE 332: C++ pointers, arrays, and references Overview of Pointers and References Often need to refer to another object –Without making a copy of the object.
CSC Programming for Science Lecture 27: Arrays as Parameters, Searching, & Sorting.
Question of the Day  What three letter word completes the first word and starts the second one: DON???CAR.
Week 6 - Friday.  What did we talk about last time?  Loop examples.
For Friday Read No quiz Program 6 due. Program 6 Any questions?
Chapter 9 Introduction to Arrays Fundamentals of Java.
Problem of the Day  Why are manhole covers round?
CSC 212 – Data Structures Lecture 28: More Hash and Dictionaries.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Lecture 5 of Computer Science II
Linked Lists in Action Chapter 5 introduces the often-used data public classure of linked lists. This presentation shows how to implement the most common.
CHP - 9 File Structures.
Lecture 2: Primitives & References
CSE 116/504 – Intro. To Computer Science for Majors II
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
Data Structures & Algorithms
Presentation transcript:

Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments problems due before class  Remove rust from summer and get back into coding  Problems designed to help learn new material, too

Primitives vs. References Primitive VariablesReference Variables  Variables are copiers holding a value  Assignment copies value  Update variable being assigned only  Aliased with assignments  Now refer to same instance  Both see updates to object  Re-assigning variable does not update aliases

Opening Question  Are array variables primitives or references?

Array Variables  Arrays are special type of object  Array variables are references in own right  Like all variables, must be instantiated before use: int[] bob = new int[30]; Car[] parkingLot = new Car[300];  Array instances aliased by assignments  Array variables like any reference variable

Memory Trace Example int[] data = new int[3]; int[] al = data; for (int i = 0; i < data.length; i++) { data[i] = i * 2; } al[0] = 5; al = new int[1]; al[0] = 7;

Entries Are Variables, Too!  Within an array entries like individual variables int[] bob = new int[30]; Car[] parkingLot = new Car[300];  bob ’s entries would be primitive variables  parkingLot ’s entries refer to instances  Entries initialized like variable when array created  bob ’s entries would all be set to 0  null stored in all entries within parkingLot

Memory Trace Example Car[] data = new Car[3]; Car[] al = data; for (int i = 0; i < data.length; i++) { data[i] = new Car(); } al[0] = new Car(); al = new Car[1]; al[0] = data[0];

Higher-Dimension Arrays  Arrays instantiated with any dimension desired  2-d array is table

Higher-Dimension Arrays  Arrays instantiated with any dimension desired  2-d array is table identifying entries by row & column int[][] pixels = new int[20][100]; pixels[1][45] = 32;

Higher-Dimension Arrays  Arrays instantiated with any dimension desired  2-d array is table identifying entries by row & column int[][] pixels = new int[20][100]; pixels[1][45] = 32;  Entries stored in virtual cube with 3-d array int[][][] bob = new Car[60][4][10]; bob[45][3][7] = new Car();  Rare to use higher dimensions, but are possible

Computer Professor MemoryHuge (> 250GB)Can’t remember 12 names Computing speed Fast (> 2 billion/second)Slow (needs fingers & toes) Takes direction Does exactly as toldLeaves toilet seat up Speed of updates Nearly instantaneousWears t-shirts from 1989 Ability to plan & reason Cannot make plans; No reasoning skills; Lacks common sense Makes (semi-)complicated plans; Good reasoning skills; Lacks common sense Computer vs. Professor

 People are very good at reasoning & analyzing  Slow computing outcome of each potential decision  Considering every possible data combinations hard  Trouble when lots of data available to be examined  Computers can perform simple tasks quickly  Maintain billions of data items within memory  Very good when at performing simple operations  Cannot create plan since lacks concept of future  To do any task, must be given specific instructions People vs. Computers

 Computers best processing huge data sets  Perform specific tasks and output results: College’s students’ transcripts available Compute & print receipt for groceries  Filter & provide few items for user to choose from Personalized recommendations from Amazon Google’s list of matching web pages  Most of year examines how to organize data  How data used determines structures selected Computers Use Collections

How Could We Do This?  Know simple way to organize data: array  Entries refer to another array to create matrices  Many limitations arise when using arrays  Must specify unchangeable size when created Pirate[] rum = new Pirate[1]; Pirate[] h2o = new Pirate[ variable ]; rum = new Pirate[60]; // old rum was lost! h2o = rum; // h20 now alias to rum’s instance  Waste memory requiring maximum size for array /* Each Amazon.com customer uses 400+MB of RAM! */ Rating[] hertz = new Rating[ ];

 Often need to keep values ordered or organized  Alphabetical list of names & phone numbers  Keep list of job bids from smallest to largest  Web pages ordered from most to least important  Desired index’s not just assigned new value  Lose current value stored at that index  Instead, must first shift values within the array Inserting into an Array 12 n e 0

 Still need to keep values ordered or organized  Removing a value presents own set of problems  Could simply assign null, but that creates a gap  Finding start & end of data hard once gaps allowed  Instead, must shift values to fill in all gaps that exist Removing From an Array 0 12 n

Your Turn  Get into your groups and complete activity

For Next Lecture  Reading from AF 7.1 – 7.10 for Friday  What are fields and methods again?  How do they get used?  What is the point of a constructor?  There is weekly assignment problem on Angel  Due before Friday’s lecture (via )  Get back into the swing of writing Java code