Algorithms.ppt
《Algorithms.ppt》由会员分享,可在线阅读,更多相关《Algorithms.ppt(107页珍藏版)》请在麦多课文档分享上搜索。
1、Algorithms,Chapter 8,天津大学软件学院,8.1 CONCEPT,INFORMAL DEFINITION Algorithm(算法): a step-by-step method for solving a problem or doing a task.(逐步解决问题或完成任务的方法)In this definition, an algorithm is independent of the computer system(独立于计算机系统). More specifically, we should also note that the algorithm accepts
2、 a list of input data and creates a list of output data.(输入一组数据,产生一组输出数据),Finding the largest integer among five integers,Input The algorithm accepts the list of five integer as input. Processing The algorithm uses five steps to find the largest integer.Output Because there are no more integers to b
3、e processed, the algorithm outputs the value of Largest, which is 13.,DEFINING ACTIONS,REFINEMENT,GENERALIZATION,8.2 THREE CONSTRUCTS,判断,顺序,循环,8.3 ALGORITHM REPRESENTATION,FLOWCHART(流程图)A flowchart is a pictorial representation of an algorithm. It shows how the algorithm flows from beginning to end.
4、,PSEUDOCODE(伪代码)Pseudocode is an Englishlike representation of an algorithm. It is part English and part structured code.(类似英语的表示方法),Write an algorithm in pseudocode that finds the average of two numbers.,AverageOfTwoInput: Two numbers Add the two numbers Divide the result by 2 Return the result by
5、step 2End,Algorithm 8.1:,Average of two,8.4 MORE FORMAL DEFINITION,Algorithm: an ordered set of unambiguous steps that produces a result and terminates in a finite time(一组明确步骤的有序集合,它产生结果并在有限时间内终止).ORDERED SET(有序集合) An algorithm must be a well-defined, ordered set of instruction.UNAMBIGUOUS STEPS (明确
6、步骤) Each algorithm must be clearly and unambiguously defined. PRODUCE A RESULT (产生结果) An algorithm must produce a result; otherwise, it is useless. The result can be data that are returned to the calling algorithm or same other effect (e.g., printing). TERMINATE IN A FINITE TIME(在有限时间内终止)An algorith
7、m must terminate (halt). If it does not (e.g., has an infinite loop), you have not created an algorithm.,8.5 SUBALGORITHMS(子算法),The principles of structured programming, require that an algorithm be broken into small units called subalgorithms (the terms subprograms, subroutines, procedures, functio
8、n, methods, and modules are also used). Each subalgorithm is in turn divided into smaller subalgorithms. The process continues until the subalgorithms become intrinsic (understood immediately).,FindLargestInput: A list of positive integers Set Largest to 0 while (more integers) 2.1 FindLarger End wh
9、ile Return LargestEnd,Algorithm 8.6:,Find largest,FindLargerInput: Largest and current integer if (the integer is greater than Largest) then 1.1 Set Largest to the value of the integer End if End,8.6 BASIC ALGORITHMS,Summation,Product,Search concept,Example of a sequential search(顺序查找),Example of a
10、binary search(折半查找),Example of bubble sort(冒泡排序),Bubble sort,Selection sort 选择排序,Insertion sort 插入排序,Correctness and Efficiency,two that should linger in your mind as you develop algorithms on your own: Correctness(正确性) Efficiency(效率),Graph of the worst-case analysis of the insertion sort algorithm,
11、Graph of the worst-case analysis of the binary search algorithm,Data Structures,天津大学软件学院,Chapter 11,A data structure uses a collection of related variables that can be accessed individually or as a whole. In other words, a data structure represents a set of data items with a specific relationship be
12、tween then.数据结构使用相关变量的集合,这些变量能够单独或作为整体被访问。数据结构代表了有特殊关系的数据的集合。,ARRAYS(数组),Imagine you have a problem that requires 20 numbers to be processed. You need to read them, process them, and print them. You must also keep these 20 numbers in memory for the duration of the program.,数组:有固定大小的、相同数据类型元素的顺序集合,TW
13、O-DIMENSIONAL ARRAY(二维数组),RECORDS(记录),A record is a collection of related elements, possibly of different types, having a single name. Each element in a record is called a field(域). A field is the smallest element of values, which in turn can be accessed for selection or manipulation. A field differ
14、s from a variable primarily in that it is part of a record.,记录是一组相关元素的集合,它们的类型可能不同,整个记录有一个名字 域是具有含义的命名数据的最小元素 域不同于变量,它是记录的一部分; 数组中所有元素都是同一类型的;记录中的元素是相同或不同的类型,Linear list(线性列表)具有顺序结构,每个元素都有唯一的后继元素,Categories of linear lists,广义表对处理列表的操作没有任何限制,数据可在任意地方进行插入和删除操作,Insertion in a linear list,Deletion from
15、a linear list,Retrieval from a linear list(检索),Traversal of a linear list(遍历),LINKED LISTS(链表),A linked list is an ordered collection of data in which each element contains the location of the next element; that is, each element contains two parts: data and link.,链表是一个有序数据的集合,每个元素包含下个元素的地址,带有头指针的Pli
16、st链表,空链表,Queue representation(队列),插入(入列),删除(出列),Enqueue operation,Dequeue operation,Three representations of a stack(堆栈),Pop operation in a stack,Push operation in a stack,Representation of a tree(树),Directed and undirected graphs(有向图和无向图),Databases,Chapter 14,天津大学软件学院,14.1 DATABASE MANAGEMENT SYSTE
17、M,A database management system (DBMS) defines, creates, and maintains a database. The DBMS also allows users controlled access to data in the database数据库管理系统是定义、创建、维护数据库的一种工具,也允许用户控制数据库中数据的存取. A DBMS is a combination of five components: hardware, software, data, users, and procedures.,A database is
18、a collection of data that is logically, but not necessarily physically, coherent. 数据库是数据在逻辑上的集合,DBA,涉及到的课程,数据结构 算法分析 数据库原理数据库应用技术 数据仓库与数据挖掘,作业,8-168-23 11-2, 11-17,11-18, 11-20,11-2211-30 12-1912-23 14-1814-22,Software Engineering,Chapter 10,天津大学软件学院,SOFTWARE LIFE CYCLE (软件生命周期),开发系统,过时吗?,使用该系统,修正该系
19、统,ANALYSIS PHASE (分析阶段)The development process starts with the analysis phase, which shows what the package should do显示程序应该做什么. In this phase, the systems analyst defines requirements that specify what the proposed system is to accomplish系统分析员定义需求,指出系统所要实现的目标. The requirements are usually stated in
20、terms that the user understands.,Define the User(定义用户) A software package may be designed for a generic user or a specific user. The user of the package must be clearly defined.Define the Needs(定义要求) In this step, the best answer comes from the user. The user, or the representative of the user, clea
21、rly defines his/her expectations of the package. Define the Requirements (定义需求) Based on the needs of the user, the analyst can exactly define the requirements for the system.Define the Methods(定义方法) Finally, after the requirements are defined in clear terms, the analyst can choose the appropriate m
22、ethods to meet those requirements.,ANALYSIS PHASE (分析阶段),DESIGN PHASE (设计阶段)The design phase defines how the system will accomplish what was defined in the analysis phase.定义系统如何完成在分析阶段所定义的需求 In the design phase, the systems are determined, and the design of the files and/or the databases is complete
23、d. 完成文件和数据库的设计Modularity (模块化) The whole package is divided into small modules. Each module is designed and tested and is linked to other modules through a main program. Tools The design phase uses several tools, the most common being a structure chart(结构图). A structure chart shows how to break your
24、 package into logical steps; each step is a separate module. The structure chart also shows the interaction between all the parts (modules).,IMPLEMENTATION PHASE (实现阶段)In this phase, you create the actual programs. Tools This phase uses several tools to show the logical flow of the programs before t
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ALGORITHMSPPT
