《計(jì)算機(jī)科學(xué)導(dǎo)論》(第三版)第08章

上傳人:za****8 文檔編號(hào):23466325 上傳時(shí)間:2021-06-09 格式:PPT 頁(yè)數(shù):40 大?。?.53MB
收藏 版權(quán)申訴 舉報(bào) 下載
《計(jì)算機(jī)科學(xué)導(dǎo)論》(第三版)第08章_第1頁(yè)
第1頁(yè) / 共40頁(yè)
《計(jì)算機(jī)科學(xué)導(dǎo)論》(第三版)第08章_第2頁(yè)
第2頁(yè) / 共40頁(yè)
《計(jì)算機(jī)科學(xué)導(dǎo)論》(第三版)第08章_第3頁(yè)
第3頁(yè) / 共40頁(yè)

下載文檔到電腦,查找使用更方便

9.9 積分

下載資源

還剩頁(yè)未讀,繼續(xù)閱讀

資源描述:

《《計(jì)算機(jī)科學(xué)導(dǎo)論》(第三版)第08章》由會(huì)員分享,可在線閱讀,更多相關(guān)《《計(jì)算機(jī)科學(xué)導(dǎo)論》(第三版)第08章(40頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、1.1 Objectives:To define an algorithm and relate it to problem solving. To define three constructssequence, selection, and repetitionand describe their use in algorithms. To describe UML diagrams and how they can be used when representing algorithms. To describe pseudocode and how it can be used whe

2、n representing algorithms. To list basic algorithms and their applications. 1.2 Objectives (continued):To describe the concept of sorting and understand the three primitive sorting algorithms. To describe the concept of searching and understand two common searching algorithms. To define subalgorithm

3、s and their relations to algorithms. To distinguish between iterative and recursive algorithms.1.3 1.4 8.1 ConceptIn this section we informally define an algorithm and elaborate on the concept using an example. Figure 8.1: Informal definition of an algorithm 1.5 Figure 8.2: Finding the largest integ

4、er among five integers 1.6 Figure 8.3: Defining actions in FindLargest algorithm 1.7 Figure 8.4: FindLargest refined 1.8 Figure 8.5: Generalization of FindLargest 1.9 1.10 8.2 Three constructsComputer scientists have defined three constructs for a structured program or algorithm. The idea is that a

5、program must be made of a combination of only these three constructs: sequence, decision (selection), and repetition. It has been proven there is no need for any other constructs. Using only these constructs makes a program or an algorithm easy to understand, debug, or change. Figure 8.6: Three cons

6、tructs 1.11 1.12 8.3 Algorithm RepresentationSo far, we have used figures to convey the concept of an algorithm. During the last few decades, tools have been designed for this purpose. Two of these tools, UML and pseudocode, are presented here. Figure 8.7: UML for three constructs 1.13 Figure 8.8: P

7、seudocode for three constructs 1.14 Algorithm 8.1 : Calculating the sum of two integers: 1.15 Algorithm 8.2 : Assigning pass/no pass grade: 1.16 Algorithm 8.3 : Assigning a letter grade: 1.17 Algorithm 8.4 : Finding the largest integer : 1.18 Algorithm 8.5 : Find the smallest integers among 1000: 1.

8、19 1.20 8.4 A More Formal DefinitionNow that we have discussed the concept of an algorithm and shown its representation, here is a more formal definition. Let us elaborate on this definition. 1.21 8.5 Basic AlgorithmsSeveral algorithms are used in computer science so prevalently that they are consid

9、ered “basic”. We discuss the most common here. This discussion is very general: implementation depends on the language. Figure 8.9: Summation algorithm 1.22 Figure 8.10: Product algorithm 1.23 Figure 8.11: Selection sort 1.24 Figure 8.12: Example of selection sort 1.25 Figure 8.13: Selection sort al

10、gorithm 1.26 Figure 8.14: Bubble sort 1.27 Figure 8.15: Example of bubble sort 1.28 Figure 8.16: Insertion sort 1.29 Figure 8.17: Example of insertion sort 1.30 Figure 8.18: An example of a sequential search 1.31 Figure 8.19: Example of a binary search 1.32 1.33 8.6 SubalgorithmsThe three programmin

11、g constructs described earlier allow us to create an algorithm for any solvable problem. The principles of structured programming, however, require that an algorithm be broken into small units called subalgorithms. Each subalgorithm is in turn divided into smaller subalgorithms. Figure 8.20: Concept

12、 of a subalgorithm 1.34 1.35 8.7 RecursionIn general, there are two approaches to writing algorithms for solving a problem. One uses iteration, the other uses recursion. Recursion is a process in which an algorithm calls itself. Figure 8.21: Iterative definition of factorial 1.36 Figure 8.22: Recursive definition of factorial 1.37 Figure 8.23: Tracing the recursive solution of factorial 1.38 Algorithm 8.6 : Iteration solution to factorial problem: 1.39 Algorithm 8.7 : A recursive solution of the factorial problem: 1.40

展開閱讀全文
溫馨提示:
1: 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!