第三章 栈与队列(第2版).pptVIP

  • 4
  • 0
  • 约2.31万字
  • 约 93页
  • 2018-03-16 发布于河南
  • 举报
第三章 栈与队列(第2版)

第三章 栈与队列 3.1 栈 ( Stack ) 栈可定义为只允许在表的末端进行插入和删除的线性表。 允许插入和删除 的一端称为栈顶 (top),另一端称 为栈底(bottom) 特点 后进先出 (LIFO) 栈的抽象数据类型 二、顺序栈 栈的其他成员函数的实现 template class T void SeqStackT::overflowProcess() //私有函数:当栈满则执行扩充栈存储空间处理 { T *newArray = new T[maxSize+stackIncreament]; //创建更大的存储数组 if (newArray==NULL) { cerr“存储分配失败!”endl; exit(1); } for (int i = 0; i = top; i++) newArray[i] = elements[i]; maxSize= maxSize+stackIncreament; delete []elements; elements = newArray; //改变elements指针 }; template class T void SeqStackT::Push(const T x) {

文档评论(0)

1亿VIP精品文档

相关文档