structure探讨一群相关的资料的的资料表示方.pptVIP

  • 1
  • 0
  • 约1.64万字
  • 约 51页
  • 2018-06-09 发布于福建
  • 举报

structure探讨一群相关的资料的的资料表示方.ppt

structure探讨一群相关的资料的的资料表示方

CHAPTER 1 CHAPTER 1 BASIC CONCEPT Data Structure What is data structure? Ans. Data structure探討一群相關資料的資料表示方 法與資料運作方法 目的 : 使用最有效率的方式,對一群相關資料進行處理 如何設計 : 1. 找出對該資料的各種運算 2. 考慮最適當的Data Structure,使得各種運算的 效率最佳 3. 設計一個完整的Algorithm How to create programs Requirements: What inputs, functions, and outputs Analysis: bottom-up vs. top-down Design: data objects and operations Refinement and Coding Verification Program Proving Testing Debugging Algorithm Definition An algorithm is a finite set of instructions that accomplishes a particular task. Criteria Input: zero more quantities are externally supplied. Output: at least one quantity is produced. definiteness: clear and unambiguous finiteness: terminate after a finite number of steps effectiveness: instruction is basic enough to be carried out Algorithm One distinguishes between an algorithm and a program, the latter of which does not have to satisfy the fourth condition (Finiteness). For example, we can think of an operating system that continues in a wait loop until more jobs are entered. 在已排序的資料中找值18 Sequential Search 第7次找到 Binary Search 第3次找到 Translating a Problem into an Algorithm Problem Devise a program that sorts a set of n= 1 integers Solution I From those integers that are currently unsorted, find the smallest and place it next in the sorted list Solution II for (i= 0; i n; i++){ Examine list[i] to list[n-1] and suppose that the smallest integer is list[min]; Interchange list[i] and list[min]; } Translating a Problem into an Algorithm Solution III Data Type Data Type A data type is a collection of objects and a set of operations that act on those objects. Example of int Objects: 0, +1, -1, ..., Int_Max, Int_Min Operations: arithmetic(+, -, *, /, and %), testing (equality/inequality), assigns, functions Data encapsulation and Data abstraction Data encapsulation or Information hiding是把資料物件的內部程式碼內容隱藏不被外部的使用者知道 目的 : 1. 讓往後可能的修改能夠局限在此程式單元之中 2. 讓程式單元不需隨著ADT內部的表示方式的改 變而修改外部的使用方式 3

文档评论(0)

1亿VIP精品文档

相关文档