SlideShare a Scribd company logo
Computer Science: A Structured Programming Approach Using C 1
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 C 2
FIGURE 8-34 Two-dimensional Array
Computer Science: A Structured Programming Approach Using C 3
FIGURE 8-35 Array Of Arrays
Computer Science: A Structured Programming Approach Using C 4
PROGRAM 8-15 Fill Two-dimensional Array
Computer Science: A Structured Programming Approach Using C 5
FIGURE 8-36 Memory Layout
Computer Science: A Structured Programming Approach Using C 6
PROGRAM 8-16 Convert Table to One-dimensional Array
Computer Science: A Structured Programming Approach Using C 7
PROGRAM 8-16 Convert Table to One-dimensional Array
Computer Science: A Structured Programming Approach Using C 8
FIGURE 8-37 Passing a Row
Computer Science: A Structured Programming Approach Using C 9
FIGURE 8-38 Calculate Average of Integers in Array
Computer Science: A Structured Programming Approach Using C 10
FIGURE 8-39 Example of Filled Matrix
Computer Science: A Structured Programming Approach Using C 11
PROGRAM 8-17 Fill Matrix
Computer Science: A Structured Programming Approach Using C 12
PROGRAM 8-17 Fill Matrix
Computer Science: A Structured Programming Approach Using C 13
8-8 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 C 14
FIGURE 8-40 A Three-dimensional Array (3 x 5 x 4)
Computer Science: A Structured Programming Approach Using C 15
FIGURE 8-41 C View of Three-dimensional Array
Computer Science: A Structured Programming Approach Using C 16
8-9 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 C 17
FIGURE 8-42 Data Structures For Calculate Row–Column Averages
Computer Science: A Structured Programming Approach Using C 18
PROGRAM 8-18 Calculate Row and Column Averages: main
Computer Science: A Structured Programming Approach Using C 19
PROGRAM 8-19 Calculate Row and Column Averages: Get Data
Computer Science: A Structured Programming Approach Using C 20
PROGRAM 8-19 Calculate Row and Column Averages: Get Data
Computer Science: A Structured Programming Approach Using C 21
PROGRAM 8-19 Calculate Row and Column Averages: Get Data
Computer Science: A Structured Programming Approach Using C 22
PROGRAM 8-19 Calculate Row and Column Averages: Get Data
Computer Science: A Structured Programming Approach Using C 23
PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
Computer Science: A Structured Programming Approach Using C 24
PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
Computer Science: A Structured Programming Approach Using C 25
PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
Computer Science: A Structured Programming Approach Using C 26
PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
Computer Science: A Structured Programming Approach Using C 27
PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
Computer Science: A Structured Programming Approach Using C 28
The efficiency of the bubble sort is O(n2).
Note
Computer Science: A Structured Programming Approach Using C 29
The efficiency of the selection sort is O(n2).
Note
Computer Science: A Structured Programming Approach Using C 30
The efficiency of the insertion sort is O(n2).
Note
Computer Science: A Structured Programming Approach Using C 31
The efficiency of the sequential search is O(n).
Note
Computer Science: A Structured Programming Approach Using C 32
The efficiency of the binary search is O(logn).
Note
Computer Science: A Structured Programming Approach Using C 33
Table 8-4 Comparison of binary and sequential searches

More Related Content

Similar to Chap-08-4.ppt

Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
ssusere6f5a11
 
Chap 02-1
Chap 02-1Chap 02-1
Chap 02-1
Navjot Singh
 
Variable-intro.pptx
Variable-intro.pptxVariable-intro.pptx
Variable-intro.pptx
ssuser5ad1571
 
Chap-14-1 (1).ppt
Chap-14-1 (1).pptChap-14-1 (1).ppt
Chap-14-1 (1).ppt
OmPrakasDas
 
Sample Programs.ppt
Sample Programs.pptSample Programs.ppt
Sample Programs.ppt
saravanakumarsoman1
 
Chap-07-1.ppt
Chap-07-1.pptChap-07-1.ppt
Chap-07-1.ppt
ISHAAGARWAL75
 
Chap-03-1.ppt
Chap-03-1.pptChap-03-1.ppt
Chap-03-1.ppt
ShraddhaPattnaik
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
AbdulSacur2
 
Lecture6
Lecture6Lecture6
Lecture6
Vijay Soni
 
test(3)arithmetic in c
test(3)arithmetic in ctest(3)arithmetic in c
test(3)arithmetic in c
Jaya Malathy
 
Chap 01-1 jwfiles
Chap 01-1 jwfilesChap 01-1 jwfiles
Chap 01-1 jwfiles
Suresh Nannuri
 
Cs8251 faq1
Cs8251 faq1Cs8251 faq1
Cs8251 faq1
tamilvanan76
 
9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt
LokeshK66
 
Pcd201516
Pcd201516Pcd201516
Pcd201516
sheikhmoidin
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
C++ Homework Help
 
9781285852744 ppt ch08
9781285852744 ppt ch089781285852744 ppt ch08
9781285852744 ppt ch08
Terry Yoast
 
Stack implementation using c
Stack implementation using cStack implementation using c
Stack implementation using c
Rajendran
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 90681061992
 
A02
A02A02
A02
lksoo
 
ch9.ppt
ch9.pptch9.ppt

Similar to Chap-08-4.ppt (20)

Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Chap 02-1
Chap 02-1Chap 02-1
Chap 02-1
 
Variable-intro.pptx
Variable-intro.pptxVariable-intro.pptx
Variable-intro.pptx
 
Chap-14-1 (1).ppt
Chap-14-1 (1).pptChap-14-1 (1).ppt
Chap-14-1 (1).ppt
 
Sample Programs.ppt
Sample Programs.pptSample Programs.ppt
Sample Programs.ppt
 
Chap-07-1.ppt
Chap-07-1.pptChap-07-1.ppt
Chap-07-1.ppt
 
Chap-03-1.ppt
Chap-03-1.pptChap-03-1.ppt
Chap-03-1.ppt
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Lecture6
Lecture6Lecture6
Lecture6
 
test(3)arithmetic in c
test(3)arithmetic in ctest(3)arithmetic in c
test(3)arithmetic in c
 
Chap 01-1 jwfiles
Chap 01-1 jwfilesChap 01-1 jwfiles
Chap 01-1 jwfiles
 
Cs8251 faq1
Cs8251 faq1Cs8251 faq1
Cs8251 faq1
 
9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt
 
Pcd201516
Pcd201516Pcd201516
Pcd201516
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
9781285852744 ppt ch08
9781285852744 ppt ch089781285852744 ppt ch08
9781285852744 ppt ch08
 
Stack implementation using c
Stack implementation using cStack implementation using c
Stack implementation using c
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 9068
 
A02
A02A02
A02
 
ch9.ppt
ch9.pptch9.ppt
ch9.ppt
 

More from valerie5142000

HOW TO MAKE YOUR OWN CAT 5 UTP Cable.ppt
HOW TO MAKE YOUR OWN CAT 5 UTP Cable.pptHOW TO MAKE YOUR OWN CAT 5 UTP Cable.ppt
HOW TO MAKE YOUR OWN CAT 5 UTP Cable.ppt
valerie5142000
 
dotNET_Overview.pdf
dotNET_Overview.pdfdotNET_Overview.pdf
dotNET_Overview.pdf
valerie5142000
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
valerie5142000
 
cpphtp4_PPT_02.ppt
cpphtp4_PPT_02.pptcpphtp4_PPT_02.ppt
cpphtp4_PPT_02.ppt
valerie5142000
 
Prog1-L3.pptx
Prog1-L3.pptxProg1-L3.pptx
Prog1-L3.pptx
valerie5142000
 
Prog1-L2.pptx
Prog1-L2.pptxProg1-L2.pptx
Prog1-L2.pptx
valerie5142000
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
valerie5142000
 

More from valerie5142000 (7)

HOW TO MAKE YOUR OWN CAT 5 UTP Cable.ppt
HOW TO MAKE YOUR OWN CAT 5 UTP Cable.pptHOW TO MAKE YOUR OWN CAT 5 UTP Cable.ppt
HOW TO MAKE YOUR OWN CAT 5 UTP Cable.ppt
 
dotNET_Overview.pdf
dotNET_Overview.pdfdotNET_Overview.pdf
dotNET_Overview.pdf
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
cpphtp4_PPT_02.ppt
cpphtp4_PPT_02.pptcpphtp4_PPT_02.ppt
cpphtp4_PPT_02.ppt
 
Prog1-L3.pptx
Prog1-L3.pptxProg1-L3.pptx
Prog1-L3.pptx
 
Prog1-L2.pptx
Prog1-L2.pptxProg1-L2.pptx
Prog1-L2.pptx
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 

Recently uploaded

一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
pchutichetpong
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
NABLAS株式会社
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 

Recently uploaded (20)

一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 

Chap-08-4.ppt

  • 1. Computer Science: A Structured Programming Approach Using C 1 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:
  • 2. Computer Science: A Structured Programming Approach Using C 2 FIGURE 8-34 Two-dimensional Array
  • 3. Computer Science: A Structured Programming Approach Using C 3 FIGURE 8-35 Array Of Arrays
  • 4. Computer Science: A Structured Programming Approach Using C 4 PROGRAM 8-15 Fill Two-dimensional Array
  • 5. Computer Science: A Structured Programming Approach Using C 5 FIGURE 8-36 Memory Layout
  • 6. Computer Science: A Structured Programming Approach Using C 6 PROGRAM 8-16 Convert Table to One-dimensional Array
  • 7. Computer Science: A Structured Programming Approach Using C 7 PROGRAM 8-16 Convert Table to One-dimensional Array
  • 8. Computer Science: A Structured Programming Approach Using C 8 FIGURE 8-37 Passing a Row
  • 9. Computer Science: A Structured Programming Approach Using C 9 FIGURE 8-38 Calculate Average of Integers in Array
  • 10. Computer Science: A Structured Programming Approach Using C 10 FIGURE 8-39 Example of Filled Matrix
  • 11. Computer Science: A Structured Programming Approach Using C 11 PROGRAM 8-17 Fill Matrix
  • 12. Computer Science: A Structured Programming Approach Using C 12 PROGRAM 8-17 Fill Matrix
  • 13. Computer Science: A Structured Programming Approach Using C 13 8-8 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:
  • 14. Computer Science: A Structured Programming Approach Using C 14 FIGURE 8-40 A Three-dimensional Array (3 x 5 x 4)
  • 15. Computer Science: A Structured Programming Approach Using C 15 FIGURE 8-41 C View of Three-dimensional Array
  • 16. Computer Science: A Structured Programming Approach Using C 16 8-9 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:
  • 17. Computer Science: A Structured Programming Approach Using C 17 FIGURE 8-42 Data Structures For Calculate Row–Column Averages
  • 18. Computer Science: A Structured Programming Approach Using C 18 PROGRAM 8-18 Calculate Row and Column Averages: main
  • 19. Computer Science: A Structured Programming Approach Using C 19 PROGRAM 8-19 Calculate Row and Column Averages: Get Data
  • 20. Computer Science: A Structured Programming Approach Using C 20 PROGRAM 8-19 Calculate Row and Column Averages: Get Data
  • 21. Computer Science: A Structured Programming Approach Using C 21 PROGRAM 8-19 Calculate Row and Column Averages: Get Data
  • 22. Computer Science: A Structured Programming Approach Using C 22 PROGRAM 8-19 Calculate Row and Column Averages: Get Data
  • 23. Computer Science: A Structured Programming Approach Using C 23 PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
  • 24. Computer Science: A Structured Programming Approach Using C 24 PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
  • 25. Computer Science: A Structured Programming Approach Using C 25 PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
  • 26. Computer Science: A Structured Programming Approach Using C 26 PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
  • 27. Computer Science: A Structured Programming Approach Using C 27 PROGRAM 8-20 Calculate Row and Column Averages: Row Averages
  • 28. Computer Science: A Structured Programming Approach Using C 28 The efficiency of the bubble sort is O(n2). Note
  • 29. Computer Science: A Structured Programming Approach Using C 29 The efficiency of the selection sort is O(n2). Note
  • 30. Computer Science: A Structured Programming Approach Using C 30 The efficiency of the insertion sort is O(n2). Note
  • 31. Computer Science: A Structured Programming Approach Using C 31 The efficiency of the sequential search is O(n). Note
  • 32. Computer Science: A Structured Programming Approach Using C 32 The efficiency of the binary search is O(logn). Note
  • 33. Computer Science: A Structured Programming Approach Using C 33 Table 8-4 Comparison of binary and sequential searches