Aalborg Media Lab 2-May-15 Exercises/Summary Lecture 10 Summary, Exercises.

Slides:



Advertisements
Similar presentations
Why not just use Arrays? Java ArrayLists.
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.
Arrays.
The simple built-in data types of the C language such as int, float, - are not sufficient to represent complex data such as lists, tables, vectors, and.
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
Lecture 05 - Arrays. Introduction useful and powerful aggregate data structure Arrays allow us to store arbitrary sized sequences of primitive values.
Introduction to Computers and Programming Lecture 17: Arrays (cont) Professor: Evan Korth New York University.
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
Aalborg Media Lab 19-Jun-15 Exercises/Summary Lecture 12 Summary, Exercises.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
1 Arrays In many cases we need a group of nearly identical variables. Example: make one variable for the grade of each student in the class This results.
1 Lecture Today’s topic Arrays Reading for this Lecture: –Chaper 11.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
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.
Arrays. Example Write a program to keep track of all students’ scores on exam 1. Need a list of everyone’s score Declare 14 double variables? What about.
Aalborg Media Lab 27-Jun-15 Workshop / Exercises Lecture 9 Summary, Exercises.
Aalborg Media Lab 28-Jun-15 Software Design Lecture 8 “Arrays”
Chapter 9 Introduction to Arrays
1 Arrays & functions Each element of an array acts just like an ordinary variable: Like any ordinary variable, you can pass a single array element to a.
Chapter 6: Arrays Java Software Solutions Third Edition
1 Lab Session-IX CSIT121 Fall 2000 w Arrays and Their Usage w Examples and Lab Exercises w Passing Arrays to Functions w Examples and Exercises w Sorting.
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
11 Chapter 8 ARRAYS Continued. 22 MULTI-DIMENSIONAL ARRAYS A one-dimensional array is useful for storing/processing a list of values. For example: –The.
© 2011 Pearson Education, publishing as Addison-Wesley 1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 6 focuses.
The University of Texas – Pan American
7. Arrays. Topics Declaring and Using Arrays Some Array Algorithms Arrays of Objects Variable Length Parameter Lists Two-Dimensional Arrays The ArrayList.
Java – Part II Lecture Notes 4. Arrays An array is a data structure that groups and organizes data l Array is a list of values (int, double, aggregates)
COMP102 Lab 081 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
AP Comp Sci A Chapter 12 - Arrays. Ch 12 Goals: Goals: Declare and create arrays Declare and create arrays Access elements in arrays Access elements in.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 6: Arrays Presentation slides for Java Software Solutions for AP* Computer Science 3rd Edition.
8-1 Chapter 8: Arrays Arrays are objects that help us organize large amounts of information Today we will focuses on: –array declaration and use –bounds.
CompSci Arrays  Aggregate data type  Deal with items of same type  Lists of words  Numbers  Analogies  Mailboxes in post office  CD racks.
1 Building Java Programs Chapter 7: Arrays These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or.
Chapter 7 Arrays 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter overview This chapter focuses on Array declaration and use Bounds checking and capacity Arrays storing object references Variable length parameter.
1 Traversal algorithms. 2 Array traversal traversal: An examination of each element of an array. Traversal algorithms often takes the following form:
© 2004 Pearson Addison-Wesley. All rights reserved October 15, 2007 Searching ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor:
Data Structure CS 322. What is an array? Initializing arrays Accessing the values of an array Multidimensional arrays LAB#1 : Arrays.
CS 139-Programming Fundamentals Lecture 11B - Arrays Adapted from a presentation by Dr. Rahman Fall 2014.
1 One Dimensional Arrays Chapter 11 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
Arrays Chapter 12. Overview Arrays and their properties Creating arrays Accessing array elements Modifying array elements Loops and arrays.
COMP More About Arrays Yi Hong June 05, 2015.
int [] scores = new int [10];
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
1 Parameter passing Call by value The caller evaluates the actual parameters and passes copies of their values to the called function. Changes to the copies.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
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 contiguous memory locations that have the same name and type. Note: an array may contain primitive data BUT an array is a data structure a collection.
Arrays. Example Write a program to keep track of all students’ scores on quiz 1. Need a list of everyone’s score Declare 14 double variables? What about.
Arrays. Arrays are objects that help us organize large amounts of information.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Lecture 5 array declaration and instantiation array reference
ARRAYS (Extra slides) Arrays are objects that help us organize large amounts of information.
Chapter VII: Arrays.
Two-Dimensional Arrays
Chapter 12 Collections.
Arrays We often want to organize objects or primitive data in a way that makes them easy to access and change. An array is simple but powerful way to.
int [] scores = new int [10];
Multidimensional Arrays
Chapter 12 Collections.
Collections.
Arrays.
Presentation transcript:

Aalborg Media Lab 2-May-15 Exercises/Summary Lecture 10 Summary, Exercises

Aalborg Media Lab 2-May-15 Summary of Arrays SD8 has focused on: –array declaration and use –passing arrays and array elements as parameters –arrays of objects –multidimensional arrays –the ArrayList class –polygons and polylines

Aalborg Media Lab 2-May-15 Array Summary An array is an ordered list of values An array of size N is indexed from zero to N-1 scores The entire array has a single name Each value has a numeric index This array holds 10 values that are indexed from 0 to 9

Aalborg Media Lab 2-May-15 Declaring and Using Arrays Declare integer array; int[] scores = new int[10]; Assigning integer to array; scores[index] = 2554; Retrieving information from array for (int i = 0; i < scores.length; i ++) { scores[i] = 0; }

Aalborg Media Lab 2-May-15 Accessing Array Data scores for (int i = 0; i < scores.length; i ++) { scores[i] = 0; }

Aalborg Media Lab 2-May-15 Random Number Generator Generating random numbers between 0 – 50, counting the occurrences of each number. Modify the range to (-25) – (25) Create a histogram of intervals of these numbers 0 – 10 | ****** 11 – 20 | **** 21 – 30 | ********** …

Aalborg Media Lab 2-May-15 Approach Generating number Random generator = new Random(); int num = generator.nextInt(51); Store the occurrence in the array occurences[num]++; 012… … 01001

Aalborg Media Lab 2-May-15 Exercises so far LectureExercises SD2 – , 2.5, 2.9, 2.11, 2.13, (2.15) SD3 – – 3.5 SD4 – , 4.8, 4.10 SD5 – , 5.2, 5.13 SD6 – SD8 – , 7.3, 7.6, 7.12