首页
友链
关于

数据结构与算法 课堂笔记 0:Abstract Data Type

02 / 27 / 2023 (最后编辑于 02 / 27 / 2023)
预计阅读时间 2 分钟

Abstract Data Type

When one search for a tool, he needn’t know how the tool have been implemented but only to know how to use and what he can get.

ADT is a package of the declarations of a data type and the operations that are meaningful to it.

We encapsulate the data type and the operations and hide them from the user.

That is to say, ADTs are implementation independent.

ADT consists:

  1. Definition of values
    1. Definition
    2. Condition (optional)
  2. Definition of operations
    1. Header (type and name of the function)
    2. Precondition (opt.)
    3. Postcondition

Data Abstraction

Data abstraction is an important method is program design.

Algorithms can be designed in terms of the ADT.

(There should be a table of phase to solve a problem)

Miscellaneous

Passing Arguments

  1. Pass by Value
int Square(int x);
  1. Pass by Reference
int Square(int *x);
// actually, this one may create a new pointer variable

   or

int Square(int &x);

Question: the security of const &?