山东大学:《数据结构》课程教学资源(PPT课件讲稿)第5章 堆栈(STACKS)Restricted version of a linear list

第5章 堆栈( STACKS) Restricted version of a inear list 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 1 第 5 章 堆栈 (STACKS)— Restricted version of a linear list

Contents 5. 1 The abstract Data Type 5.2 Derived classes and inheritance 派生类和继承 5.3 Formula-Based Representation 栈的公式化描述 5.4 Linked Representation 栈的链表描述 n55 Applications应用 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 2 Contents ◼ 5.1 The Abstract Data Type ◼ 5.2 Derived Classes and Inheritance ◼ 派生类和继承 ◼ 5.3 Formula-Based Representation ◼ 栈的公式化描述 ◼ 5.4 Linked Representation ◼ 栈的链表描述 ◼ 5.5 Applications 应用

5. 1 The abstract data type Definition a stack is a linear list in which insertion(addition and deletion take place at the same end the end is called top. the other end of the list is called the bottom e1re2,e3r…reir…ren-1en bottom top 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 3 5.1 The Abstract data type ◼ Definition A stack is a linear list in which insertion(addition) and deletion take place at the same end, The end is called top. The other end of the list is called the bottom ◼ e1 , e2 , e3 , …, ei , …, en-1 , en ↑ ↑ bottom top

Stack configurations E←top D←top D←top CBA C←top B B B A←- bottom A← bottom ←- bottom A← botton Inserto Delete Delete sTack is a table of LIFO ( Last-In, First-Out) 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 4 Stack configurations D ←top C B A ←bottom E ←top D C B A ←bottom D ←top C B A ←bottom C ←top B A ←bottom ⚫Stack is a table of LIFO (Last-In, First-Out) . Insert() Delete Delete

Stack ADT AbstractDataT ype Stack t instances linear list of elements one end is called bottom the other is the top 操作 Create; create an empty stack IsEmpty ( return true if stack if empty, false otherwise IsFullo; return true if stack is full, false otherwise Top; return the top element of stack Add(x); add element x to the stack Delete(x); delete top element of stack and put it in x 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 5 Stack ADT AbstractDataType Stack { instances linear list of elements; one end is called bottom; the other is the top 操作 Create( );create an empty stack; IsEmpty( );return true if stack if empty,false otherwise IsFull( );return true if stack is full,false otherwise Top( );return the top element of stack Add(x);add element x to the stack. Delete(x);delete top element of stack and put it in x. }

52 Derive class and inheritance(派生类和继承) a Class b that is a specialized or restricted version of another class a may be derived(派生) from the class, a is called based class and b the derived cass. B inherits(继承) all of the members- public protected and private of A, and all data members and functions of a are associated with every object of type B. Furthermore a class can be derived from more than one class, e. g. from A, C 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 6 5.2 Derive class and inheritance(派生类和继承) ◼ A Class B that is a specialized or restricted version of another class A may be derived (派生)from the class. A is called Based class and B the derived class. B inherits (继承) all of the members –public, protected and private of A, and all data members and functions of A are associated with every object of type B. Furthermore a class can be derived from more than one class, e.g. from A,C

Three ways to inherent Using class header syntax(语法) to specify class B: public A //public Class b inherent all public and protected members of A class B: public A, private C Class b inherent the public and protected members of A but all the public and protected members of C become the private members of B. class B: protected A All public and protected member of a become the protected member of B NOTE: in all model of inheritance, the private members of a remain private to a and are not accessible from members of b 山东大学计算机科学与技术学院数据结构第5章堆栈 7
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 Three ways to inherent ◼ Using class header syntax (语法) to specify class B: public A //public ◼ Class B inherent all public and protected members of A class B: public A, private C ◼ Class B inherent the public and protected members of A, but all the public and protected members of C become the private members of B. class B: protected A ◼ All public and protected member of A become the protected member of B. ◼ NOTE: in all model of inheritance, the private members of A remain private to A and are not accessible from members of B. 7

usage If X is of type B, we can use function F on X by writing X Fo only when f is a public member of either b or a 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 usage ◼ If X is of type B, we can use function F on X by writing X.F () only when F is a public member of either B or A. 8

5.3 formula-based representation Since a stack is a linear list with the restriction that additions and deletions take place and the same end If we use formula-based representation top element of stack- elemenet (length-1; and bottom=element[01 The class stack defined in program 5.1 is a derived class of linearlist( Program 3. 1), where the inheritance model is private, it means that the public and protected members of linearlist are accessible bu members of stack, but not by stack instances 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 9 5.3 formula-based representation Since a stack is a linear list with the restriction that additions and deletions take place and the same end. If we use formula-based representation, top element of stack= elemenet[length-1]; and bottom=element[0] The class stack defined in Program 5.1 is a derived class of LinearList( Program 3.1), where the inheritance model is private, it means that the public and protected members of LinearList are accessible bu members of Stack, but not by stack instances

1. Program 3.1 template class linearlist{∥公式化描述的线性表 public: LinearList(int MaxListSize 10) LinearListoi delete l element;) bool Isempty o const i return length ==0; y int Lengthy const i return length; y bool Find(int k, T& x) const int Search(const t& x) const LinearList& delete(int k t&X LinearList& insert(int k, const T& x) void Output(ostream& out) const private: int length int Maxsize; T * element. 山东大学计算机科学与技术学院数据结构第5章堆栈
山东大学计算机科学与技术学院 数据结构 第5章 堆栈 10 1. Program 3.1 template class LinearList { //公式化描述的线性表 public: LinearList(int MaxListSize = 10); ~LinearList() { delete [] element; } bool IsEmpty() const { return length == 0; } int Length() const { return length; } bool Find(int k, T& x) const; int Search(const T& x) const; LinearList& Delete(int k, T& x); LinearList& Insert(int k, const T& x); void Output(ostream& out) const; private: int length; int MaxSize; T *element; };
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《C语言程序设计》课程教学资源(PPT课件讲稿)第2章 数据类型与常用库函数.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)设计模式 Design Pattern(3).ppt
- 安徽理工大学:《汇编语言》课程教学资源(PPT课件讲稿)第二章 80x86计算机组织.ppt
- SVM原理与应用(PPT讲稿).pptx
- MSC Software Corporation:Dynamic System Modeling, Simulation, and Analysis Using MSC.EASY5(Advanced Class).ppt
- 《程序设计语言原理》课程教学资源(PPT课件讲稿)形式语义学 Formal Semantics.ppt
- 中国科学技术大学:《算法设计与分析》课程教学资源(PPT课件讲稿)第一部分 概率算法(黄刘生).ppt
- 《计算机组成原理》课程教学资源(PPT课件讲稿)第二章 电子计算机中信息的表示及其运算.ppt
- 虚拟存储(PPT课件讲稿)Virtual Memory.ppt
- Network Alignment(PPT讲稿)Treating Networks as Wireless Interference Channel.pptx
- 中国科学技术大学:《高级操作系统 Advanced Operating System》课程教学资源(PPT课件讲稿)第四章 分布式进程和处理机管理.ppt
- 东南大学:《操作系统概念 Operating System Concepts》课程教学资源(PPT课件讲稿)08 Main Memory(主讲:张柏礼).ppt
- 《高级语言程序设计》课程教学资源(试卷习题)试题三(无答案).doc
- 《数字图像处理》课程教学资源(PPT课件)第五章 代数运算.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)类和对象 Class and Object.ppt
- Detecting Evasion Attack at High Speed without Reassembly.ppt
- 《数字图像处理》课程教学资源(PPT课件)第七章 图像分割.ppt
- 中国科学技术大学:《信息论与编码技术》课程教学资源(PPT课件讲稿)第2章 离散信源及其信息测度.pptx
- 清华大学出版社:《计算机网络安全与应用技术》课程教学资源(PPT课件讲稿)第6章 黑客原理与防范措施.ppt
- 大连工业大学:《数据结构》课程教学资源(PPT课件讲稿,共十章,路莹).pps
- 澳门大学:统计机器翻译领域适应性研究 Domain Adaptation for Statistical Machine Translation Master Defense.pptx
- 北京大学:《高级软件工程》课程教学资源(PPT课件讲稿)第九讲 静态代码的可信性分析概述.ppt
- 《C语言程序设计》课程教学资源(PPT课件讲稿)第10章 指针.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)分布对象 Distributed Objects(1).ppt
- 四川大学:《操作系统 Operating System》课程教学资源(PPT课件讲稿)Chapter 1 Computer System Overview.ppt
- 安徽理工大学:《算法设计与分析 Algorithm Design and Analysis》课程教学资源(PPT课件讲稿)第一章 导引与基本数据结构.ppt
- 《结构化程序设计》课程教学资源(PPT课件讲稿)第4章 VB控制结构.ppt
- 香港城市大学:PERFORMANCE ANALYSIS OF CIRCUIT SWITCHED NETWORKS(PPT讲稿).pptx
- 上海交通大学:《计算机组成原理 Computer Organization》课程教学资源(PPT课件讲稿)Chapter 4A The Processor, Part A.pptx
- 清华大学出版社:《计算机网络安全与应用技术》课程教学资源(PPT课件讲稿)第5章 Windows NT/2000的安全与保护措施.ppt
- 《人工智能》课程教学资源(PPT课件讲稿)第13章 智能优化计算简介.ppt
- 《计算机网络技术及应用》课程教学资源(PPT课件讲稿)第十一章 网络安全.ppt
- 《数字图像处理》课程教学资源(PPT课件讲稿)第八章 形态学处理.ppt
- 北京师范大学现代远程教育:《计算机应用基础》课程教学资源(PPT课件讲稿)第四篇 数据处理与数据分析.ppsx
- 《ARM Cortex-M3权威指南》课程教学资源(PPT课件讲稿)Cortex M3 存储系统访问.pptx
- 《人工智能》课程教学资源(PPT课件讲稿)Ch10 Auto-encoders(Auto and variational encoders v.9r6).pptx
- 西安电子科技大学:《操作系统 Operating Systems》课程教学资源(PPT课件讲稿)Chapter 05 输入输出 Input/Output.ppt
- 《计算机应用基础》课程教学资源(PPT课件讲稿)第5章 文件文档工具.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)敏捷软件开发 Agile Software Development.ppt
- 《信息安全工程》课程教学资源(PPT课件讲稿)第3章 密码学基础.ppt