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.

Slides:



Advertisements
Similar presentations
Chapter 9: Advanced Array Manipulation
Advertisements

Computer Science: A Structured Programming Approach Using C Converting File Type A rather common but somewhat trivial problem is to convert a text.
Computer Science: A Structured Programming Approach Using C1 8-4 Array Applications In this section we study two array applications: frequency arrays with.
11.5 SORTING ARRAY Sorting is the process of transforming a list into an equivalent list, in which the elements are arranged in ascending or descending.
An Introduction to Programming with C++ Fifth Edition
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
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.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
Arrays Data Structures - structured data are data organized to show the relationship among the individual elements. It usually requires a collecting mechanism.
Introduction to Programming with C++ Fourth Edition
C++ for Engineers and Scientists Third Edition
Chapter 8 Arrays and Strings
Programming Logic and Design Fourth Edition, Comprehensive
Arrays (Part II). Two- and Multidimensional Arrays Two-dimensional array: collection of a fixed number of components (of the same type) arranged in two.
Chapter 8 Multidimensional Arrays C Programming for Scientists & Engineers with Applications by Reddy & Ziegler.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
Processing Arrays Lesson 8 McManusCOP Overview One-Dimensional Arrays –Entering Data into an Array –Printing an Array –Accumulating the elements.
Chapter 9: Advanced Array Concepts
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Computer Science: A Structured Programming Approach Using C1 8-5 Sorting One of the most common applications in computer science is sorting—the process.
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 1.
Chapter 8 Arrays and Strings
Arrays Chapter 7. 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores : Inspecting.
Array Processing.
Lecture Contents Arrays and Vectors: Concepts of array. Memory index of array. Defining and Initializing an array. Processing an array. Parsing an array.
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 8 Multidimensional Arrays.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
Arrays  Array is a collection of same type elements under the same variable identifier referenced by index number.  Arrays are widely used within programming.
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.
Introduction to C++ Programming Language Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University,
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 10: Applications of Arrays (Searching and Sorting) and the vector Type.
Working with Arrays in MATLAB
An Introduction to Programming with C++ Fifth Edition Chapter 11 Arrays.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
© 2004 Pearson Addison-Wesley. All rights reserved October 15, 2007 Searching ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor:
1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C arrays ❏ To be able to pass arrays and array elements to functions.
Searching Chapter 13 Objectives Upon completion you will be able to:
3.3 Complexity of Algorithms
IN THE NAME OF ALLAH WHO IS THE MOST BENEFICENT AND MOST MERCIFUL.
Chapter 9 Processing Lists with Arrays. Class 9: Arrays Understand the concept of random numbers and how to generate random numbers Describe the similarities.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
Processing Arrays Lesson 9 McManusCOP Overview One-Dimensional Arrays –Entering Data into an Array –Printing an Array –Accumulating the elements.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 6 l Array Basics l Arrays in Classes and Methods l Programming.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
Arrays Chapter 7. 2 Declaring and Creating Arrays Recall that an array is a collection of elements all of the _____________ Array objects in Java must.
1. 2  Introduction  Array Operations  Number of Elements in an array One-dimensional array Two dimensional array Multi-dimensional arrays Representation.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the relationship between arrays and pointers ❏ To understand the.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
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.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Lecture #15 ARRAYS By Shahid Naseem (Lecturer). 2 ARRAYS DEFINITION An array is a sequence of objects of same data type. The objects in an array are also.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Chapter 15 Lists Objectives
Chapter 8 Arrays Objectives
Topics discussed in this section:
Sorting Data are arranged according to their values.
Topics discussed in this section:
3-7 Sample Programs This section contains several programs that you should study for programming technique and style. Computer Science: A Structured.
Chapter 15 Lists Objectives
Chapter 8 Arrays Objectives
Sorting Data are arranged according to their values.
Topics discussed in this section:
Chapter 8 Arrays Objectives
Presentation transcript:

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 arrays because the data are organized linearly in only one direction. Many applications require that data be stored in more than one dimension. One common example is a table, which is an array that consists of rows and columns. Declaration Passing A Two-Dimensional Array Topics discussed in this section:

Computer Science: A Structured Programming Approach Using C2 FIGURE 8-34 Two-dimensional Array

Computer Science: A Structured Programming Approach Using C3 FIGURE 8-35 Array Of Arrays

Computer Science: A Structured Programming Approach Using C4 PROGRAM 8-15Fill Two-dimensional Array

Computer Science: A Structured Programming Approach Using C5 FIGURE 8-36 Memory Layout

Computer Science: A Structured Programming Approach Using C6 PROGRAM 8-16Convert Table to One-dimensional Array

Computer Science: A Structured Programming Approach Using C7 PROGRAM 8-16Convert Table to One-dimensional Array

Computer Science: A Structured Programming Approach Using C8 FIGURE 8-37 Passing a Row

Computer Science: A Structured Programming Approach Using C9 FIGURE 8-38 Calculate Average of Integers in Array

Computer Science: A Structured Programming Approach Using C10 FIGURE 8-39 Example of Filled Matrix

Computer Science: A Structured Programming Approach Using C11 PROGRAM 8-17Fill Matrix

Computer Science: A Structured Programming Approach Using C12 PROGRAM 8-17Fill Matrix

Computer Science: A Structured Programming Approach Using C Multidimensional Arrays Multidimensional arrays can have three, four, or more dimensions. The first dimension is called a plane, which consists of rows and columns. The C language considers the three-dimensional array to be an array of two-dimensional arrays. Declaring Multidimensional Arrays Topics discussed in this section:

Computer Science: A Structured Programming Approach Using C14 FIGURE 8-40 A Three-dimensional Array (3 x 5 x 4)

Computer Science: A Structured Programming Approach Using C15 FIGURE 8-41 C View of Three-dimensional Array

Computer Science: A Structured Programming Approach Using C Programming Example— Calculate Averages We previously introduced the programming concept known as incremental development. In this chapter we develop an example—calculate average—that contains many of the programming techniques. First Increment: mainYour First C Second Increment: Get Data Third Increment: Calculate Row Averages Fourth Increment: Calculate Column Averages Fifth Increment: Print Tables Topics discussed in this section:

Computer Science: A Structured Programming Approach Using C17 FIGURE 8-42 Data Structures For Calculate Row–Column Averages

Computer Science: A Structured Programming Approach Using C18 FIGURE 8-43 Calculate Row–Column Average Design

Computer Science: A Structured Programming Approach Using C19 PROGRAM 8-18Calculate Row and Column Averages: main

Computer Science: A Structured Programming Approach Using C20 PROGRAM 8-19Calculate Row and Column Averages: Get Data

Computer Science: A Structured Programming Approach Using C21 PROGRAM 8-19Calculate Row and Column Averages: Get Data

Computer Science: A Structured Programming Approach Using C22 PROGRAM 8-19Calculate Row and Column Averages: Get Data

Computer Science: A Structured Programming Approach Using C23 PROGRAM 8-19Calculate Row and Column Averages: Get Data

Computer Science: A Structured Programming Approach Using C24 PROGRAM 8-20Calculate Row and Column Averages: Row Averages

Computer Science: A Structured Programming Approach Using C25 PROGRAM 8-20Calculate Row and Column Averages: Row Averages

Computer Science: A Structured Programming Approach Using C26 PROGRAM 8-20Calculate Row and Column Averages: Row Averages

Computer Science: A Structured Programming Approach Using C27 PROGRAM 8-20Calculate Row and Column Averages: Row Averages

Computer Science: A Structured Programming Approach Using C28 PROGRAM 8-20Calculate Row and Column Averages: Row Averages

Computer Science: A Structured Programming Approach Using C Software Engineering In this section, we discuss two basic concepts: testing and algorithm efficiency. To be effective, testing must be clearly thought out. We provide some concepts for testing array algorithms by studying sorting and searching. We then continue the algorithm efficiency discussion started in Chapter 6. Testing Sorts Testing Searches Analyzing Sort Algorithms Analyzing Search Algorithms Topics discussed in this section:

Computer Science: A Structured Programming Approach Using C30 Table 8-2Recommended Sort Test Cases

Computer Science: A Structured Programming Approach Using C31 When testing an array search, always access the first and last elements. Note

Computer Science: A Structured Programming Approach Using C32 Table 8-3Test cases for searches

Computer Science: A Structured Programming Approach Using C33 The efficiency of the bubble sort is O(n 2 ). Note

Computer Science: A Structured Programming Approach Using C34 The efficiency of the selection sort is O(n 2 ). Note

Computer Science: A Structured Programming Approach Using C35 The efficiency of the insertion sort is O(n 2 ). Note

Computer Science: A Structured Programming Approach Using C36 The efficiency of the sequential search is O(n). Note

Computer Science: A Structured Programming Approach Using C37 The efficiency of the binary search is O(logn). Note

Computer Science: A Structured Programming Approach Using C38 Table 8-4 Comparison of binary and sequential searches