COSC 1P03 Introduction to Data Structures 1.1 COSC 1P03  Audience  planning to major in COSC (prereq. 1P02 60%)  Lectures (AS202, AS217), labs (J301),

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays.
Advertisements

Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Arrays.
Arrays and Matrices CSE, POSTECH. 2 2 Introduction Data is often available in tabular form Tabular data is often represented in arrays Matrix is an example.
Arrays Chapter 6. Outline Array Basics Arrays in Classes and Methods Sorting Arrays Multidimensional Arrays.
Arrays.
Arrays. 1D Array Representation In C 1-dimensional array x = [a, b, c, d] map into contiguous memory locations Memory abcd start location(x[i]) = start.
COSC 1P02 Introduction to Computer Science 1.1 Cosc 1P03 Week 12 Lecture slides “Example is not the main thing in influencing others, it is the only thing.”
Arrays. Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left
Lecture 05 - Arrays. Introduction useful and powerful aggregate data structure Arrays allow us to store arbitrary sized sequences of primitive values.
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
An Introduction to Programming with C++ Fifth Edition
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
Alice in Action with Java
Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.
Lab 11 rArrays rExercises Note: Read the whole Chapter 8.
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
Introduction of Arrays. Arrays Array form an important part of almost all programming language. It provides a powerful feature and can be used as such.
Chapter 8 Arrays and Strings
1 CSCE 1030 Computer Science 1 Arrays Chapter 7 in Small Java.
Chapter 9 Introduction to Arrays
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 13 – Having Fun with Arrays in Java Webpage:
Multi-Dimensional Arrays
A First Book of ANSI C Fourth Edition
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
Chapter 8 Arrays and Strings
French Territory of St. Pierre CSE 114 – Computer Science I Arrays.
COSC 1P03 Data Structures and Abstraction 1.1 Cosc 1P03 Week 1 Lecture slides “For myself, I am an optimist--it does not seem to be much use being anything.
Chapter 2 ARRAYS.
Lecture Contents Arrays and Vectors: Concepts of array. Memory index of array. Defining and Initializing an array. Processing an array. Parsing an array.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Data Structures – Week #1 Introduction. February 17, 2012Borahan Tümer, Ph.D.2 Goals We will learn methods of how to (explicit goal) organize or structure.
M180: Data Structures & Algorithms in Java Arrays in Java Arab Open University 1.
An Introduction to Programming with C++ Fifth Edition Chapter 11 Arrays.
Addressing Modes Chapter 6 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Arrays.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 6 l Array Basics l Arrays in Classes and Methods l Programming.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Chapter 8: Part 3 Collections and Two-dimensional arrays.
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
1. 2  Introduction  Array Operations  Number of Elements in an array One-dimensional array Two dimensional array Multi-dimensional arrays Representation.
Arrays in java Unit-1 Introduction to Java. Array There are situations where we might wish to store a group of similar type of values in a variable. Array.
INTRODUCTION OF ARRAY. Topics To Be Discussed………………………. Introduction Types of array One Dimensional Array Internal representation of one-dimensional array.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
ARRAYS Multidimensional realities Image courtesy of
1 ENERGY 211 / CME 211 Lecture 4 September 29, 2008.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
Chapter 9 Introduction to Arrays Fundamentals of Java.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Arrays. 1D Array Representation In C++ 1-dimensional array x = [a, b, c, d] map into contiguous memory locations Memory abcd start location(x[i]) = start.
C++ Arrays SarMag Trimester 31 C++ Arrays. C++ Arrays SarMag Trimester 32 C++ Arrays An array is a consecutive group of memory locations. Each group is.
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
KUKUM-06/07 EKT120: Computer Programming 1 Week 6 Arrays-Part 1.
CSI 3125, Data Types, page 1 Data types Outline Primitive data types Structured data types Strings Enumerated types Arrays Records Pointers Reading assignment.
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
Array, Strings and Vectors
Arrays An Array is an ordered collection of variables
Introduction To Programming Information Technology , 1’st Semester
Chapter 7 Part 2 Edited by JJ Shepherd
Arrays Week 2.
Presentation transcript:

COSC 1P03 Introduction to Data Structures 1.1 COSC 1P03  Audience  planning to major in COSC (prereq. 1P02 60%)  Lectures (AS202, AS217), labs (J301), tutorials (AS204), Help Desk (J328)  Web  COSC 1P03:  COSC:  Course Outline  Textbook  Software  Marking scheme  Assignment submission/return  Plagiarism  Succeeding in COSC 1P03  labs/assignments

COSC 1P03 Introduction to Data Structures 1.2 Chapter 1 Arrays

COSC 1P03 Introduction to Data Structures 1.3 Arrays  Collection  like Pictures & Sounds  Elements (components)  any type (primitive or object)  Non-sequential processing  not just in order of occurrence  selective (random) processing

COSC 1P03 Introduction to Data Structures 1.4 Above-average Rainfall  Months with rainfall above monthly average for year  Non-sequential processing  must process all data to compute average  then process the data to list those above average  12 months  array of 12 double values  declare then create  memory model  Average  loop to read and sum  length attribute  setting element value  getting element value  then compute average  Listing those above average  second loop

COSC 1P03 Introduction to Data Structures 1.6 Class Statistics  Report with average and standard deviation of student marks  data file  Array of Student objects  Array size not known  choose suitable size (constant)  keep count  Array organization  not all elements used  Standard Deviation formula:

COSC 1P03 Introduction to Data Structures 1.9  Reading data  termination  no more data  no more space  error message?  Computing standard deviation  array as parameter  count also parameter  second traversal

COSC 1P03 Introduction to Data Structures 1.11 University Statistics  University enrolments at universities in a number of departments  produce summary table  Data  Multi-dimensional  university  department  Multi-dimensional array  declaration  rows are departments  columns are universities

COSC 1P03 Introduction to Data Structures 1.14  Processing  reading statistics  computing department sums  processing by row  computing university sums  processing by column  computing grand total  processing all elements  producing summary table

Consolidation

COSC 1P03 Introduction to Data Structures 1.17 Single-dimensional Arrays  Collection  Use  declaration  creation  subscripting (indexing)  zero-based  NullPointerException  ArrayIndexOutOfBoundsException  length attribute  Memory model  Reference type  array assignment  element assignment

COSC 1P03 Introduction to Data Structures 1.20 Processing One-dimensional Arrays  “Right-Sized”  size known a priori or computable  create with known size  all elements have values  traversal patterns  “Variable-sized”  array size not known  choose arbitrary size (constant)  keep count in ancillary variable  not all elements have values  traversal pattern

COSC 1P03 Introduction to Data Structures 1.23 Multidimensional Arrays  2 or more dimensions  e.g. table  like Picture  Declaration  Creation  Subscripting  length  “Variable-sized”  fill upper left corner  one counter for each dimension

COSC 1P03 Introduction to Data Structures 1.25 Processing 2-Dimensional Arrays  Random access  a[i][j]  look-up table  Sequential access  row-major order  lexicographic order  algorithm  column-major order  algorithm  regular arrays  Enrolment system example

COSC 1P03 Introduction to Data Structures 1.28 Array Representation  single dimensional  contiguous allocation  value/object/array is sequence of consecutive cells  address(a[i]) = address(a) + i  s  where  s = size of element type  if not zero-based subscripting  address(a[i]) = address(a) + (i-l)  s  where  l = lower bound

COSC 1P03 Introduction to Data Structures 1.29  Multi-dimensional  row-major vs column-major  lexicographic (row-major) ordering  consider as array of rows  address(a[i]) = address(a) + i  S  where  S = size of row ( S=a[0].length  s )  start of i th row  address(a[i][j]) = address(a[i]) + j  s  substitution gives  address(a[i][j]) = address(a) + i  S + j  s  for non-zero based  address(a[i][j]) = address(a) + (i-l r )  S + (j-l c )  s

Row-major Column-major

COSC 1P03 Introduction to Data Structures 1.31 Arrays of Arrays  Non-contiguous allocation  each row contiguous  Memory model  Addressing  address(a[i][j] = content(address(a)+i  4) + j  s  Access  row-major order more efficient  Java uses array-of-arrays allocation  Ragged array