表栈队列 高文宇 gwyy@163.com §1 抽象数据类型 定义1(ADT): Data Type = { Objects } ? { Operations } 示例1: int = { 0, ?1, ?2, ? ? ?, INT_MAX, INT_MIN } ? { ?, ?, ?, ?, ?, ? ? ? } 在面向对象程序设计中,类(对象)就可以视为ADT。 §2 表ADT Objects: ( item0, item1, ??? , itemN?1 ) Operations: ? Finding the length, N, of a list. ? Printing all the items in a list. ? Making an empty list. ? Finding the k-th item from a list, 0 ? k N. ? Inserting a new item after the k-th item of a list, 0 ? k N. ? Deleting an item from a list. ? Finding next of the current item from a list. ? Finding previous of the current item from a list. 表的简单数组实现 链表 链表的插入 链表的删除 双向循环链表 表的应用—多项式ADT Objects : P ( x ) = a1 x e1 + ??? + an x en ; a set of ordered pairs of ei , ai where ai is the coefficient and ei is the exponent. ei are nonnegative integers. Operations: ? Finding degree, max { ei }, of a polynomial. ? Addition of two polynomials. ? Subtraction between two polynomials. ? Multiplication of two polynomials. ? Differentiation of a polynomial. 多项式的数组实现 多项式的链式实现 表的应用—多重表 表的应用—多重表 §3 栈ADT 栈(Stack):后进先出(LIFO)。 Objects: A finite ordered list with zero or more elements. Operations: ? Int IsEmpty( Stack S ); ? Stack CreateStack( ); ? DisposeStack( Stack S ); ? MakeEmpty( Stack S ); ? Push( ElementType X, Stack S ); ? ElementType Top( Stack S ); ? Pop( Stack S ); 栈的链表实现 栈的数组实现 栈的应用—平衡符号 栈的应用—后缀表达式 后缀表达式的计算 中缀表达式转换成后缀表达式 后缀表达式的计算 中缀转后缀 中缀转后缀 中缀转后缀 栈的应用—函数调用 §4 队列ADT 队列(Queue):先进先出(FIFO)。 Objects: A finite ordered list with zero or more elements. Operations: ? int IsEmpty( Queue Q ); ? Queue CreateQueue( ); ? DisposeQueue( Queue Q ); ? MakeEmpty( Queue Q ); ? Enqueue( ElementType X, Queue Q ); ? ElementType Front( Queue Q ); ? Dequeue( Queue Q ); 队列的实现 队列的应用 计算机作业提交 售票窗口排队 计算机网络 排队论(Queuing theory):用概率方法计算排队的等待时间,队列长度等。 作业 看程序: list.c,list.h—链表ADT的实现 stackar.c,stackar.h—栈的数组实现 stackli.c,stackli.h—栈的链式实现 queue.c,queue.h—队列的数组实现 再见 再见 * array[ i ] = itemi ? MaxSize has to be estimated. Address Content array+i ite
您可能关注的文档
最近下载
- 军人内部关系教育PPT课件.pptx
- 湖北省部分重点中学2026届高三第一次联考政治试卷含答案.pdf VIP
- 科隆流量计算机SUMMIT8800手册.pdf VIP
- 2025年中考语文二轮复习备考:小说阅读理解提高练(含答案).docx VIP
- EN 60204-1-2006 中文版.pdf VIP
- 密切内部关系课件.-战友之间密切内部关系共18页文档.ppt VIP
- ce认证电气安全要求-en60204-1.pdf VIP
- 人教版(新教材)七年级上册数学综合与实践《设计学校田径运动会比赛场地》教学课件.pptx VIP
- 过敏性鼻炎的用药指导.pptx VIP
- 正天unique knee推广宣传包unqiue12134.pptx VIP
原创力文档

文档评论(0)