《数据结构的算法在C++中的应用》(英文版)Chapter 6 Queue

Chapter 6 Q ueue
Chapter 6 Queue

6.1 Definition Definition a queue is a linear list in which additions and deletions take place at different ends It is also called a first-in-first-out list The end at which new elements are added is called the rear The end from which old elements are deleted is called the front
6.1 Definition • Definition: A queue is a linear list in which additions and deletions take place at different ends. It is also called a first-in-first-out list. The end at which new elements are added is called the rear. The end from which old elements are deleted is called the front

6.1 Definition Sample queues front rear front rear front rear AB C B C B C D Delete a Add d
6.1 Definition • Sample queues front rear front rear front rear A B C B C B C D Delete A Add D

6.2 ADT AbstractData Type Queue Instances ordered list of elements one end is called the front the other is the rear operations Create(: Create an empty queue IsEmptyo: Return true if queue is empty, return false otherwise IsFullo return true if queue is full, return false otherwise
6.2 ADT AbstractDataType Queue{ instances ordered list of elements;one end is called the front; the other is the rear; operations Create():Create an empty queue; IsEmpty():Return true if queue is empty,return false otherwise; IsFull():return true if queue is full, return false otherwise;

6.2 ADT Firsto: return first element of the queue Lasto return last element of the queue Add (): add element x to the queue Delete(x): delete front element from the queue and put it in x;
6.2 ADT First():return first element of the queue; Last():return last element of the queue; Add(x):add element x to the queue; Delete(x):delete front element from the queue and put it in x; }

6.3formula-based representation front rear Q Maxsize -1 ueue ABC 0j[1][2] the queue size =rear+ an empty queue has rear--1
6.3formula-based representation the queue size =rear+1; an empty queue has rear=-1 A B C …… Queue: front rear Maxsize-1 [0] [1] [2] [n-1]

6.3formula-based representation To add an element rear-rear+l; queuerear=x; To delete an element: two methods 1)frontfront+1; O( 2)shift the queue one position left. O(n)
6.3formula-based representation To add an element: rear=rear+1; queue[rear]=x; To delete an element: two methods: 1) front=front+1; O(1) 2) shift the queue one position left. O(n)

6.3formula-based representation Figure 6.3 front rear front rear front rear ABC B BIC D
6.3formula-based representation Figure 6.3 front rear front rear front rear A B C … B C … B C D …

6.3formula-based representation Figure 6.4 front rear ABC p Free space
6.3formula-based representation Figure 6.4 … A B C D E Front rear Free space

6.3formula-based representation as the figure6. 4 shows each deletion causes front to move right by 1 So there will be times when rearmaxsize-1 and front>o At these times the queue is not full, there is space at the left end of it
6.3formula-based representation As the figure6.4 shows ,each deletion causes front to move right by 1 So,there will be times when rear=maxsize-1 and front>0 At these times the queue is not full,there is space at the left end of it
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《数据结构的算法在C++中的应用》(英文版)Chapter 5 Stack.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 4 Arrays and Matrix.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 3 Linear List.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 2 Program performance.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 1 preface.ppt
- 《数据结构的算法在C++中的应用》(英文版)Textbook.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第9章 宏.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第8章 数据访问页.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第7章 建立Access报表.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第6章 Access窗体的操作.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第5章 查询的创建及应用.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第4章 建构Access数据库表.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第3章 创建Access数据库.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第2章 Access 2002应用基础.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第1章 数据库原理及基本概念.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第12章 综合实例应用.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第11章 Access数据库的管理.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第10章 Access模块和应用程序设计.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)各章习题参考答案.ppt
- 西北工业大学:《计算机系统结构》总复习及模拟试题.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 7 Hashing.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 8 Binary and other trees.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 9 Priority Queues.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 11 Search Trees.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 12 Graphs.ppt
- 四川电力职业技术学院:《ASP网络程序设计》目录.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第五章 数据库基础知识.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第二章 ASP初步.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第一章 网络程序设计概述.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第三章 ASP脚本语 VBScript.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第四章 ASP常用内部对象.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第六章 ASP数据库编程.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第八章 使用第三方组件.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第七章 文件存取组件及其它组.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第一章 网络程序设计概述.ppt
- 《ASP动态网页设计》电子教案.doc
- 《ASP动态网页设计》教学大纲.doc
- 《ASP动态网页设计》教学进度表.doc
- 《ASP动态网页设计》进度计划.doc
- 《ASP动态网页设计》课程设计指导书.doc