Neal Stublen Computer Memory (Simplified)  Remember, all programming decisions came down to a true or false evaluation  Consider.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 1.
Advertisements

Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
One Dimensional Arrays
Programming Logic and Design Sixth Edition
Arrays.
Understanding Arrays and How They Occupy Computer Memory
Line Efficiency     Percentage Month Today’s Date
 2003 Prentice Hall, Inc. All rights reserved. 1 Sorting Arrays Sorting data –Important computing application –Virtually every organization must sort.
Searching Arrays Linear search Binary search small arrays
Arrays Data Structures - structured data are data organized to show the relationship among the individual elements. It usually requires a collecting mechanism.
C++ for Engineers and Scientists Third Edition
Arrays. Objectives Learn about arrays Explore how to declare and manipulate data into arrays Learn about “array index out of bounds” Become familiar with.
Chapter 9 Introduction to Arrays
- SEARCHING - SORTING.  Given:  The array  The search target: the array element value we are looking for  Algorithm:  Start with the initial array.
Homework –Continue Reading K&R Chapter 2 –We’ll go over HW2 –HW3 is posted Questions?
1 Introduction to Arrays Problem: –Input 5 scores, compute total, average –Input Example –test scores,employees,temperatures.
1 Microsoft Visual Basic 2010 Arrays. 2 Using a One-Dimensional Array Lesson A Objectives After completing this lesson, you will be able to:  Declare.
Chapter 9: Advanced Array Concepts
Data Collections: Dictionaries CSC 161: The Art of Programming Prof. Henry Kautz 11/4/2009.
VB Arrays Chapter 8 Dr. John P. Abraham Professor UTPA.
+ ARRAYS - SEARCHING - SORTING Dr. Soha S. Zaghloul updated by Rasha M. AL_Eidan 2015.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
Searching Damian Gordon. Google PageRank Damian Gordon.
Lists Computers and Programming. Agenda What is a list? How to access elements in the list? The for statement Operations on lists Looping with.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
Arrays The concept of arrays Using arrays Arrays as arguments Processing an arrays data Multidimensional arrays Sorting data in an array Searching with.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 5 Arrays.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
11 PART 2 ARRAYS. 22 PROCESSING ARRAY ELEMENTS Reassigning Array Reference Variables The third statement in the segment below copies the address stored.
Arrays An array is an indexed data structure which is used to store data elements of the same data type. An array is an indexed data structure which is.
14 BirthMonth1February BirthMonth CE : Fundamental Programming Techniques.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Chapter 9 Introduction to Arrays Fundamentals of Java.
13 Arrays CE : Fundamental Programming Techniques June 161.
Common Elementary Algorithms Some of the basic but frequently used algorithms for manipulating arrays. These algorithms are so important that: a)Some programming.
Objectives You should be able to describe: One-Dimensional Arrays
Jan 2016 Solar Lunar Data.
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Q1 Jan Feb Mar ENTER TEXT HERE Notes

Average Monthly Temperature and Rainfall
Arrays, For loop While loop Do while loop
2017 Jan Sun Mon Tue Wed Thu Fri Sat
Gantt Chart Enter Year Here Activities Jan Feb Mar Apr May Jun Jul Aug
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Starting Out with Programming Logic & Design
Tutorial 11 Arrays Tutorial 11: Arrays.
Jan Sun Mon Tue Wed Thu Fri Sat
Electricity Cost and Use – FY 2016 and FY 2017
QUIZ.
Programming Logic and Design Fifth Edition, Comprehensive
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE

Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
TIMELINE NAME OF PROJECT Today 2016 Jan Feb Mar Apr May Jun
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Pilot of revised survey
Presentation transcript:

Neal Stublen

Computer Memory (Simplified)  Remember, all programming decisions came down to a true or false evaluation  Consider a true decision to have a value of 1 and a false decision to have a value of 0  Now we can say all programming decisions come down to a 1 or 0 evaluation

Computer Memory (Simplified) Computer Memory (4GB) 04,294,967,295  4 GB  4,096 MB = 4 * 1024 MB  4,194,304 KB = 4 * 1024 * 1024 KB  4,294,967,296 bytes = 4 * 1024 * 1024 * 1024 bytes  Each byte can store a value from 0 to 255

Computer Memory (Simplified) Operating SystemDisplayApp Object Code Constant Data (Static) Available Memory intint intint intint App string 04,294,967,295 intint ? ?

What’s an array?  Every variable represents a value stored somewhere in the computer’s memory  We may want to store a group of very similar values  An array represents a collection of values stored side-by-side in the computer’s memory  Each value is accessed according to its offset from the first value in the array

What is an array? int string int string int string int “Elements” in the array We can declare variables for individual values. We can also declare an “array” of values.

Possible Use of an Array? int Track one high scores in a game… int Track top five high scores in a game…

Declaring an Array num highScore1 = 0 num highScore2 = 0 num highScore3 = 0 num highScore4 = 0 num highScore5 = 0

Declaring an Array num highScore1 = 0 num highScore2 = 0 num highScore3 = 0 num highScore4 = 0 num highScore5 = 0 num highScores[5] = 0, 0, 0, 0, 0

Using Arrays  The size of the array is the number of elements in the array  Each element in the array exists at a specific index (sometimes referred to as a subscript of the array)  Index values typically start at zero  highScores[0] = 5400 Assign the first element in the array a value of 5400

Initializing an Array  How can we reset or initialize an array so all the elements have the same value? num highScores[5] for index = 0; index < 5; index++ highScores[index] = 0 endfor

Benefits of an Array? We begin tracking 5 high scores… num highScores[5] for index = 0; index < 5; index++ highScores[index] = 0 endfor

Benefits of an Array? num NUM_HIGHSCORES = 5 num highScores[NUM_HIGHSCORES] for index = 0; index < NUM_HIGHSCORES; index++ highScores[index] = 0 endfor If we want to track more high scores, we just change the value of NUM_HIGHSCORES instead of adding highScore6, etc.

Manage High Scores  What logic is necessary to track a set of high scores?  Start with a set of zero scores  Enter a new score and display the list of updated high scores

Mapping Index Values string months[12] = "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" num month_num = 10 // October string abbrev = months[month_num – 1]

Searching an Array for index = 0; index < array_size; index++ if array[index] == search_value then // found a match endif endfor Requires anywhere from 1 to array_size iterations to find a match.

Binary Search  If the data in the array is sorted, we can reduce the number of searches Like guessing the number between 1 and 100. Start in the middle and keep dividing the array in half

Common Problems  Array bounds num values[5] values[18] = -6// Out of bounds!! for index = 0; index <= 5; index += 1 output values[index] // Out of bounds!! endfor

Summary  Storing data in arrays  Using constants with arrays  Using loops to iterate over array elements  Searching an array

Heart Evaluation  What logic is necessary to recommend an appropriate exercising heart rate? years = bpm years = bpm years = bpm years = bpm years = bpm Over 70 years = bpm  A user can enter an age and see the recommended range.