8-4 array applications

38
Computer Science: A Structured Programming Approach Using C 1 -4 Array Applications In this section we study two array applications: In this section we study two array applications: frequency arrays with their graphical frequency arrays with their graphical representations and random number representations and random number permutations. permutations. Frequency Arrays Histograms Random Number Permutations Topics discussed in this section: Topics discussed in this section:

Upload: dylan-slater

Post on 31-Dec-2015

33 views

Category:

Documents


1 download

DESCRIPTION

8-4 Array Applications. In this section we study two array applications: frequency arrays with their graphical representations and random number permutations. Topics discussed in this section:. Frequency Arrays Histograms Random Number Permutations. FIGURE 8-14 Frequency Array. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 1

8-4 Array Applications

In this section we study two array applications: In this section we study two array applications: frequency arrays with their graphical representations frequency arrays with their graphical representations and random number permutations.and random number permutations.

Frequency ArraysHistogramsRandom Number Permutations

Topics discussed in this section:Topics discussed in this section:

Page 2: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 2

FIGURE 8-14 Frequency Array

Page 3: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 3

FIGURE 8-15 Frequency Histogram

Page 4: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 4

FIGURE 8-16 Histogram Program Design

Page 5: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 5

PROGRAM 8-7 Frequency and Histogram

Page 6: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 6

PROGRAM 8-7 Frequency and Histogram

Page 7: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 7

PROGRAM 8-7 Frequency and Histogram

Page 8: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 8

PROGRAM 8-7 Frequency and Histogram

Page 9: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 9

PROGRAM 8-7 Frequency and Histogram

Page 10: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 10

PROGRAM 8-7 Frequency and Histogram

Page 11: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 11

PROGRAM 8-7 Frequency and Histogram

Page 12: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 12

PROGRAM 8-7 Frequency and Histogram

Page 13: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 13

PROGRAM 8-7 Frequency and Histogram

Page 14: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 14

FIGURE 8-17 Design for Random Number Permutations

Page 15: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 15

PROGRAM 8-8 Generate a Permutation

Page 16: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 16

PROGRAM 8-8 Generate a Permutation

Page 17: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 17

PROGRAM 8-8 Generate a Permutation

Page 18: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 18

PROGRAM 8-8 Generate a Permutation

Page 19: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 19

PROGRAM 8-8 Generate a Permutation

Page 20: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 20

8-5 Sorting

One of the most common applications in computer One of the most common applications in computer science is sorting—the process through which data are science is sorting—the process through which data are arranged according to their values. We are arranged according to their values. We are surrounded by data. If the data are not ordered, we surrounded by data. If the data are not ordered, we would spend hours trying to find a single piece of would spend hours trying to find a single piece of information. information.

Selection SortBubble SortInsertion SortTesting Sorts

Topics discussed in this section:Topics discussed in this section:

Page 21: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 21

FIGURE 8-18 Selection Sort Concept

Page 22: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 22

FIGURE 8-19 Selection Sort Example

Page 23: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 23

FIGURE 8-20 Design for Selection Sort

Page 24: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 24

PROGRAM 8-9 Selection Sort

Page 25: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 25

PROGRAM 8-9 Selection Sort

Page 26: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 26

FIGURE 8-21 Bubble Sort Concept

Page 27: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 27

FIGURE 8-22 Bubble Sort Example

Page 28: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 28

FIGURE 8-23 Bubble Sort Design

Page 29: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 29

PROGRAM 8-10 Bubble Sort

Page 30: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 30

PROGRAM 8-10 Bubble Sort

Page 31: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 31

FIGURE 8-24 Insertion Sort Concept

Page 32: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 32

FIGURE 8-25 Insertion Sort Example

Page 33: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 33

FIGURE 8-26 Insertion Sort Design

Page 34: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 34

PROGRAM 8-11 Insertion Sort

Page 35: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 35

PROGRAM 8-11 Insertion Sort

Page 36: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 36

PROGRAM 8-12 Testing Sorts

Page 37: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 37

PROGRAM 8-12 Testing Sort

Page 38: 8-4   Array Applications

Computer Science: A Structured Programming Approach Using C 38

Table 8-1 Sort Exchanges and Passes