1 / 15
文档名称:

零基础学数据结构----队列.doc

格式:doc   大小:249KB   页数:15
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

零基础学数据结构----队列.doc

上传人:小s 2022/4/19 文件大小:249 KB

下载得到文件列表

零基础学数据结构----队列.doc

相关文档

文档介绍

文档介绍:pdfMachine
I s a pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and presers platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
-个元索仃且只仃一个直接前驱元索,除了垠
• 222 •
• 221 •
pdfMachine
I s a pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine.
Get yours now!
pdfMachine
I s a pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seco nds and preserve the in tegrity of your origi nal docume nts. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine・
Get yours now!
・217・
pdfMachine
I s a pdf writer that produces quality PDF files with ease!
Produce quality PDF files in seco nds and preserve the in tegrity of your origi nal docume nts. Compatible across
nearly all Windows platforms, if you can print from a windows application you can use pdfMachine・
Get yours now!
后一个尤素%外,每一个尤素有FI只仃一个宜接后继尤素。数据尤素Z间的关系是一对一的关系。
基本操作集合
队列的基木操作主耍有下面6种:
InitQueue(&Q):初始化操作,建立一个空队列Q。这就像II常牛活中,火车站儕栗处新增加了 一个售票窗口,这样就町以新增一队用來排队买票。
QueueEmpty(Q):若Q为空队列,返回1,否则返回0。这就像口常生活中,火车窗口前是否 还有人排队买漿。
EnterQueue(&):插入元素x到队列Q的队尾。这就像H常牛活中,新来买票的人要在队列 的最后一样。
DeleteQueue(&Q&c):删除Q的队首元索,并用c返回其值。这就像买过栗的推在队头的人离 开队列。
Gethead(Q.&e):用e返冋Q的队首尤素。这就像询问排队买票的人是谁。
ClearQueue(&Q):将队列Q消空。这就像排队买栗的人全部买完了栗,离开队列。

队列冇两种存储表示:顺序存储和链式存储。采用顺序存储结构的队列被称Z为顺序队列,采用链 式存储结构的队列被称之为链式队列。

顺序队列通常采用一维数组进行存储。其中,连续的存储单尤依次存放队列中的尤素。同时,使用 两个指针分别农小数组中存放的第一个元索和最后一个元素的位置。其屮,指向第一个元素的指针被称 为队头指针front,。
,队列中的元素存放在数组中,用队头指针from指向第一个元素a,队尾指针指向最后 一个元素ho
a
b
c
d
e
f
g
h
? r
front rear
图5・2顺序队列示总图
为了方便用C语言描述,我们约定:初始化建立空队列时,front=rear=0,队头指针front和队尾指 针rea