Complex Array Structures

Slides:



Advertisements
Similar presentations
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Advertisements

Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Fall 2001(c)opyright Brent M. Dingle 2001 Arrays Brent M. Dingle Texas A&M University Chapter 9 – Sections 1 and 2 (and some from Mastering Turbo Pascal.
Percent This slide needs the title “Percent”, your name, and two pictures that represent percent. Choose a nice background and apply it to all of your.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part D (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part B (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Top Down Design Brent M. Dingle Texas A&M University Chapter 4 – Section 1 (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Fall 2001(c)opyright Brent M. Dingle 2001 Simple Sorting Brent M. Dingle Texas A&M University Chapter 10 – Section 1 (and some from Mastering Turbo Pascal.
A Simple Program CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002.
Loops Brent M. Dingle Texas A&M University Chapter 7 – part C (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Fall 2001(c)opyright Brent M. Dingle 2001 Multidimensional Arrays Brent M. Dingle Texas A&M University Chapter 10 – Section 2, part B (and some from Mastering.
Fall 2001(c)opyright Brent M. Dingle 2001 Abstract Data Types (ADTs) Brent M. Dingle Texas A&M University Chapter 8 – Sections 2 and 3 (and some from Mastering.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
Latitude and Longitude
Chapter 2 – part b Brent M. Dingle Texas A&M University
Concepts of Object Oriented Programming
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
MAP ELEMENTS.
Brent M. Dingle Texas A&M University Chapter 6, Sections 1 and 2
Lecture 25 The Tao that can be talked about is not the true Tao
Complex data types Complex data types: a data type made of a complex of smaller pieces. Pascal has four very commonly used complex data types: strings,
Make your index card look like a test!!
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
Latitude and Longitude
Pascal Winter 2010/ Course.
Primitive Types Vs. Reference Types, Strings, Enumerations
Writing An Essay Outline
Arrays, Part 1 of 2 Topics Definition of a Data Structure
(c)opyright Brent M. Dingle 2001
Structures Lesson xx In this module, we’ll introduce you to structures.
Building Java Programs Chapter 2
Simplifying Flow of Control
CMPE 152: Compiler Design September 18 Class Meeting
One-Dimensional Array Introduction Lesson xx
Set, Combinatorics, Probability & Number Theory
Relational Operators Operator Meaning < Less than > Greater than
U.S. Mountain Range Quiz U.S Mountain Ranges 3. What is this called?
Brent M. Dingle Texas A&M University Chapter 12 – section 1
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.
Coding Concepts (Data- Types)
Turbo Pascal Units (TPU)
Procedures Brent M. Dingle Texas A&M University
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Fall 2018 CISC124 2/15/2019 CISC124 TA names and s will be added to the course web site by the end of the week. Labs start next week in JEFF 155:
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Westward Expansion Postcards.
Chapter 16: Check Digit Systems, Continued
Winter 2019 CMPE212 4/7/2019 CMPE212 – Reminders
Latitude and Longitude Notes
Variables Here we go.
Simple Branches and Loops
Chapter 2 – part a Brent M. Dingle Texas A&M University
Latitude and Longitude Notes
(c)opyright Brent M. Dingle 2001
CMPE 152: Compiler Design February 21 Class Meeting
Brent M. Dingle Texas A&M University Chapter 5 – Section 2-3
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Text Features 7th Grade Literature.
ECE 352 Digital System Fundamentals
Brent M. Dingle Texas A&M Directory Structure
Brent M. Dingle Texas A&M University Chapter 5 – Section 1
Variables and Constants
Chapter 1 Section 7 How do you read a map?
Week 7 - Monday CS 121.
Section 6 Primitive Data Types
Chapter 1, Lesson 1, Reading Maps
Presentation transcript:

Complex Array Structures Brent M. Dingle Texas A&M University Chapter 10 – Section 2, part A (and some from Mastering Turbo Pascal 5.5, 3rd Edition by Tom Swan) Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 Array of Grades Pretend we had 50 students. Each has a numeric grade 0 to 100 Each has a letter grade, A, B, C, D, F We want to store that information in the computer. How do we do it (with what we know so far) ? Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 Parallel Arrays Parallel arrays associate data by storing things in some significant order. In the example above we would associate a number with each student 1 to 50. Then we could use TWO arrays of types: TYPE GradeType = ‘A’..’F’; ScoreList = array[1..50] of real; GradeList = array[1..50] of GradeType; VAR NumberGrades : ScoreList; LetterGrades : GradeList; Fall 2001 (c)opyright Brent M. Dingle 2001

Parallel Arrays – picture Fall 2001 (c)opyright Brent M. Dingle 2001

Parallel Arrays (cont) So as you can see each student number is used to index into either array. Notice this means if we change the order of one array, we MUST change the order of the second array in exactly the same way. Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 Arrays of Strings So far we have seen arrays of type char, integer, real, perhaps boolean. What about strings? Sure why not: TYPE NAME_LIST = array [1..20] of string; The above is completely valid. Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 Challenge (no grade) Using an array of strings (all last names) Create a program that will alphabetize them. This strongly relates to section 10.1 Fall 2001 (c)opyright Brent M. Dingle 2001

So if strings are arrays… Can we have an array of arrays? Yep. The easiest way to explain this is using an array of enumerated types and an array of numbers. Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 A room’s exits Let us create some very simple rooms, that have only exits north, east, south and/or west. Let us create a map of rooms where each room is given a number 1 to [number_of_rooms]. How would we represent this in a computer? Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 A picture to help Fall 2001 (c)opyright Brent M. Dingle 2001

(c)opyright Brent M. Dingle 2001 How do we ever Represent something like that? It’s actually pretty easy. Come to class and find out how. (of course I may need to be asked =) Fall 2001 (c)opyright Brent M. Dingle 2001

End Complex Arrays, part A Fall 2001 (c)opyright Brent M. Dingle 2001