Arrays. Real-world Scenario PLU code is missing for a product you are buying at the grocery counter. Associate may use a cheat sheet showing PLU code.

Slides:



Advertisements
Similar presentations
CSE305 – Programming Languages Daniel R. Schlegel April 25, 2011 “Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought,
Advertisements

Arrays and ArrayLists Ananda Gunawardena. Introduction Array is a useful and powerful aggregate data structure presence in modern programming languages.
Understanding the Need for Sorting Records
Repetition Control Structures
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 6: Odds and Ends  Formatted Output  Random numbers.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 2, Lecture 2.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
Copyright 2008 by Pearson Education Building Java Programs Subtype Polymorphism; Sorting (an extended programming example)
Friday, December 29, 2006 Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration. - Stan Kelly-Bootle.
Chapter 7 & 8- Arrays and Strings
Arrays.
How to answer Section B (January 2012 example) YEAR 12 REVISION.
Chapter 7 Queues. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 7-2 Chapter Objectives Examine queue processing Define a queue abstract.
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Lists in Python.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Using Advanced Formatting and Analysis Tools. 2 Working with Grouped Worksheets: Grouping Worksheets  Data is entered simultaneously on all worksheets.
Exploring Engineering Chapter 3, Part 2 Introduction to Spreadsheets.
French Territory of St. Pierre CSE 114 – Computer Science I Arrays.
Introduction to Programming Design School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 1, Friday 01/17/2003) (Continued)
Chapter 7 Array processing. Objectives To introduce arrays and the uses of arrays To develop pseudocode algorithms for common operations on arrays To.
Array Processing.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
Arrays The concept of arrays Using arrays Arrays as arguments Processing an arrays data Multidimensional arrays Sorting data in an array Searching with.
BUILDING JAVA PROGRAMS CHAPTER 7 Arrays. Exam #2: Chapters 1-6 Thursday Dec. 4th.
CS107 References and Arrays By Chris Pable Spring 2009.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Lesson Year 1 CS112/0401/V1 LESSON 6 DESIGN TOOL PSEUDOCODE  Program Design Language (PDL)  Represent logic in English-like manner  Easier to.
Neal Stublen Computer Memory (Simplified)  Remember, all programming decisions came down to a true or false evaluation  Consider.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
CSC 107 – Programming For Science. Today’s Goal  Become familiar with simple arrays  Declaring an array variable  Assigning data to array entries 
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
Sorting: Selection Sort Damian Gordon. Sorting: Selection Sort OK, so we’ve seen a way of sorting that easy for the computer, now let’s look at a ways.
5.3 Sorting Techniques. Sorting Techniques Sorting is the process of putting the data in alphabetical or numerical order using a key field primary key.
Arrays. Related data items Collection of the same types of data. Static entity – Same size throughout program.
Homework due Test the random number generator Create a 1D array of n ints Fill the array with random numbers between 0 and 100 Compute and report the average.
EE 422C Day 2 Java, Eclipse. Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
Master File Update Processing. Objectives On completing this section you should be able to: w Distinguish between online processing and batch processing.
Arrays Dr. Jose Annunziato. Arrays Up to this point we have been working with individual primitive data types Arrays allow working with multiple instances.
Structuring Data: Arrays ANSI-C. Representing multiple homogenous data Problem: Input: Desired output:
Introduction to Arrays. Objectives Distinguish between a simple variable and a subscripted variable. Input, output, and manipulate values stored in a.
Arrays.
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
Module 1: Array ITEI222 - Advance Programming Language.
MULTI-DIMENSIONAL ARRAYS 1. Multi-dimensional Arrays The types of arrays discussed so far are all linear arrays. That is, they all dealt with a single.
Array Applications. Objectives Design an algorithm to load values into a table. Design an algorithm that searches a table using a sequential search. Design.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
Arrays Chap. 9 Storing Collections of Values 1. Introductory Example Problem: Teachers need to be able to compute a variety of grading statistics for.
CIS 115 AID Peer Educator/cis115aid.com FOR MORE CLASSES VISIT
CIS 115 Slingshot Academy / Tutorialrank.com Tutorialrank.com For More Tutorials
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
COP 3275 – Finishing Loops and Beginning Arrays Instructor: Diego Rivera-Gutierrez.
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
CIS 115 AID Teaching Effectively/cis115aid.com FOR MORE CLASSES VISIT
Topic 21 arrays - part 1 Copyright Pearson Education, 2010 Based on slides by Marty Stepp and Stuart Reges from "Should.
CIS 115 Slingshot Academy / cis115.com
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Entry Ticket: Algorithms and Program Construction
Introduction to Algorithms
Algorithm & Programming
What’s cheating and what is not?
CHAPTER 5A Loop Structure
ALGORITHMS & FLOWCHARTING II
Arrays Part 1 Topic 19 - Stan Kelly-Bootle
Module 4 Loops and Repetition 4/15/2019 CSE 1321 Module 4.
Tables and Functions #31.
Presentation transcript:

Arrays

Real-world Scenario PLU code is missing for a product you are buying at the grocery counter. Associate may use a cheat sheet showing PLU code for each product – it works like an array.

Historical snippets … BASIC & FORTRAN : array index started at 1 COBOL? Modern languages use index starting at 0 How about Visual Basic?

Array index start with 0 or 1? "Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." -- Stan Kelly-Bootle

Array index start with 0 or 1?

Scenario: Max price Let us say we want to read list of prices from the user and find the max price. Do we need an array?

Find max price: pseudocode item_number = 0 DOWHILE not eof item_number = item_number + 1 read item_price[item_number] ENDDO max_price_item = 0 max_price = 0.00 FOR i = 1 to item_number do IF max_price < item_price[i ] THEN max_price_item = i; max_price = item_price[i ]; ENDIF ENDFOR print max_price_item, max_price

Find max price: no arrays item_number = 0 max_price_item = 0 max_price = 0.00 DOWHILE not eof item_number = item_number + 1 read item_price IF max_price < item_price THEN max_price_item = i; max_price = item_price; ENDIF ENDDO print max_price_item, max_price

When arrays are needed? Only if we are going to use all those individual input values again.

Do we need arrays? Mortgage amortization table expansion – show the output for user-specified year

Do we need arrays? Compute total ticket sales/donations for the day

Do we need arrays? Find max, min, average air-fare paid by customers

Do we need arrays? Find the median air-fare paid by customers

Do we need arrays? Output all the airfare amounts in sorted order

Do we need arrays? Keeping track of your score at Golf course

Arrays Easy access Fixed size When bigger size is needed, we need to allocate new array and copy the current contents over. Use ArrayList for varying array sizes (not covered in this course)

Multi-dimensional arrays Students’ scores in one assignment int scores[student_index]

Multi-dimensional arrays Students’ scores in all assignments int scores[assignment_index][student_index]

Multi-dimensional arrays Students’ scores in all assignments for several sessions of that course int scores[session_index][assignment_index][student_index]