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.

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

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.
CSCI 1100/ , 6.2, 6.4 April 12, 15, 17.
Lecture 6 b Last time: array declaration and instantiationarray declaration and instantiation array referencearray reference bounds checkingbounds checking.
CSC Programming for Science Lecture 30: Pointers.
Computer Science A 10: 20/3. Array Array: Sequence of values of the same type Construct array: new double[10] Store in variable of type double[] double[]
Pointer. Warning! Dangerous Curves C (and C++) have just about the most powerful, flexible and dangerous pointers in the world. –Most other languages.
Datalogi A 8: 27/10. Array Array: Sequence of values of the same type Construct array: new double[10] Store in variable of type double[] double[] data.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
Chapter 9 Introduction to Arrays
Lecture 5 of Computer Science II Arrays Instructor: Mr.Ahmed Al Astal.
More Arrays Length, constants, and arrays of arrays By Greg Butler.
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.
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.
Chapter 8 Arrays and Strings
File Processing - Indexing MVNC1 Indexing Jim Skon.
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
CSC 107 – Programming For Science. Today’s Goal Variables  Variable  Variable name location to store data  Only for humans; 0 x 7E8A2410 harder to.
CSC 213 – Large Scale Programming. Dictionaries in Real World  Often need large database on many machines  Split search terms across machines  Updating.
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.
What is an Array? An array is a collection of variables. Arrays have three important properties: –group of related items(for example, temperature for.
ARRAYS Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall
IT253: Computer Organization
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.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
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!
M180: Data Structures & Algorithms in Java Arrays in Java Arab Open University 1.
LECTURE 34: MAPS & HASH CSC 212 – Data Structures.
CSC 107 – Programming For Science. Today’s Goal  Become familiar with simple arrays  Declaring an array variable  Assigning data to array entries 
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 35: COLLISIONS CSC 212 – Data Structures.
CSC 212 – Data Structures Lecture 26: Hash Tables.
CSC 212 – Data Structures Lecture 2: Primitives, References, & Classes.
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.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
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!
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Question of the Day  What three letter word completes the first word and starts the second one: DON???CAR.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
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?
CSE 351 Caches. Before we start… A lot of people confused lea and mov on the midterm Totally understandable, but it’s important to make the distinction.
CSC 212 – Data Structures Lecture 28: More Hash and Dictionaries.
Lecture 5 of Computer Science II
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 – 1D Lists
CSE 326: Data Structures Lecture #14
Arrays.
Presentation transcript:

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 to singular  Makes masculine word into a feminine one What is this special word?

English Conundrum

Announcements

Primitives vs. References Primitive VariablesReference Variables  Variables hold actual value  Assignment copies value  Update variable being assigned only  Aliased with assignments  Both 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  Can be set to null to mark there is no array  Cannot use until after have instantiated array int[] bob = new int[30]; Car[] parkingLot = new Car[300];  Variables aliased by any assignments  Can deduce, array variables always references  May hold primitive data, but these are separate issue

Array Variables  Can be set to null to mark there is no array  Cannot use until after have instantiated array int[] bob = new int[30]; Car[] parkingLot = new Car[300];  Variables aliased by any assignments  Can deduce, array variables always references  May hold primitive data, but these are separate issue

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 entries  parkingLot ’s entries refer to instances  Entries initialized like variable when array created entries  bob ’s entries would all be set to 0 entries  null stored in all entries in 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]; data[0] = data[1];

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][18] = 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][18] = 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][18] = 32;  Entries stored in virtual cube with 3-d array int[][][] bert = new int[60][4][10]; bert[45][3][7] = 42;  Rare to use higher dimensions, but is possible

Computer Professor MemoryHuge (> 250GB)Can’t remember 18 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 array 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 Inserting into an Array 12 n e 0

 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 Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 array Inserting into an Array 12 n e 0

 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 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 Removing From an Array 0 12 n

 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 Removing From an Array 0 12 n

 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

 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

 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

 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

 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

 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

 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

 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

 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  Moving to review OO concerns next week  How do we write & use classes on our own?  Instances can differ, but how is this expressed?  What is an instance variable & how is it used?  What does static mean? When would we want it?  There is weekly assignment problem on Angel  Due before Wednesday’s lecture (via Submitter)  Get back into the swing of writing Java code