数据结构基础之栈的顺序存储表示与实现.doc
文本预览下载声明
数据结构基础之栈的顺序存储表示与实现
一、栈的定义
栈是限定仅在表尾进行插入或删除操作的线性表。
栈的表尾称为栈顶,表头称为栈底,不含元素的空表称为空栈。
栈的抽象数据类型定义:
{
数据对象:={|(- ,=1,2,...,,=0}
数据关系:1={|-1,(- ,=2,...,}
基本操作:
() 构造一个空栈
() 栈存在则栈被销毁
() 栈存在则清为空栈
() 栈存在则返回,否则
() 栈存在则返回的元素个数,即栈的长度
(,) 栈存在且非空则返回的栈顶元素
(,) 栈存在则插入元素为新的栈顶元素
(,) 栈存在且非空则删除的栈顶元素并用返回其值
(,())栈存在且非空则从栈底到栈顶依次对的每个数据元素调用函数()一旦()失败,则操作失败
}
二、栈的表示和实现
栈的存储方式:
1、顺序栈:利用一组地址连续的存储单元依次存放自栈底到栈顶的数据元素,同时附设指针指示栈顶元素在顺序栈中的位置
2、链栈:利用链表实现
顺序栈的类语言定义:
{
*;
*; 设栈顶栈底两指针的目的是便于判断栈是否为空
; 栈的当前可使用的最大容量.
};
顺序栈的的模块说明:
{
*;
*;
;
};
;
( );
( );
( );
( );
( );
( , );
( , );
( , );
( , (*)());
( ) {
=( *)(__ *());
(!)x();
=;
=__;
;
}
( ); {
}
( ); {
=;
}
( ); {
(==) ;
;
}
( ); {
; *;
=0;
=;
(!=) {++; ++; }
}
( , ); {
(==) ;
=*();
;
}
( , ); {
( - =) {
=( *) (,
( + ) * ());
(!)x();
=+;
+=;
}
*++=;
;
}
( , ); {
(==)
;
=*--;
;
}
( , (*)()); {
}
以上伪代码的语言源码
三、总结
栈的定义
栈的顺序存储实现
daily morning exercises or class-break setting-up exercise and discipline inspection and appraisal of public signs;2, daily cleaning and inspection;3, the daily student school appearance, dress, wearing school card check;4, the daily duty guide to the leadership class discipline three rounds.Weekly moral education work:L, the flag raising ceremony and the national flag speech under the flag raising ceremony held on Monday;2, every week a class meeting, the meeting;3, every week two exercises, cleaning and hygiene, behavior norms, attendance situation published cloth appraisal, and the issue of the code of conduct;;4, weekly work week.Monthly moral education work:1, at least once a month, the theme of education activities,
显示全部