ImageVerifierCode 换一换
格式:DOCX , 页数:5 ,大小:15.39KB ,
资源ID:16654796      下载积分:5 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-16654796.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数据结构队列Queues.docx)为本站会员(b****7)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

数据结构队列Queues.docx

1、数据结构队列QueuesQueuesImportant points to remember about a Queue:Queue FIFO First-In-First-Out DSA Queue is a Data Structure where you can insert from one end called “REAR” and delete from the other end called “FRONT”.Implementation of a Queue: a) As an array static DSi) Linear Queue uses Linear arrayii

2、) Circular Queue uses Circular arrayb) As a Linked List dynamic DSa) Implementation of a queue:As an arrayWhen the Queue is empty:Front = -1Rear = -1When the Queue has only one item:Front = 0Rear = 0When the Queue has more than one item:Front =0Rear 01. Queue Overflow: Trying to Insert an element in

3、 a queue when the queue is FULL.This condition should not arise. To avoid this error condition, always check for the position of REAR before inserting a new value in the queue. If REAR = max-1 (the last index position of the array) - this means the REAR has reached the maximum size of the array and

4、there is no more space for the new data.2. Queue Underflow: Trying to delete an item from an empty queue.In order to avoid this error situation always check for Front= -1 before trying to delete any value.Algorithm for inserting data in a Linear Queue (as an array):1. If rear=max-1 /max is the maxim

5、um size of the array and we check with max-1 if rear is pointing to the last position in the arrayDisplay “queue full”Exit2. If Front = Rear = -1 /Q is emptya.front = front+1b.Go to step 33. Rear=Rear+1/ data is inserted at the rear4. Queue rear =newdataAlgorithm for deleting data from a linear queu

6、e (as an array): 1. if front = -1/ there is no data in the queueDisplay “queue empty”Exit2. if front = rear front = rear =-13. delete the value at queuefront4. front=front+1Note : Always remember : In a Queue For every Insert: Rear = Rear +1After every Delete : Front = Front + 1The values are never

7、decremented in the case of an insert or a delete in a queueImplementation of a queue as a circular queue ( CQ):For the empty CQ :Front =-1Rear =-1For the CQ with only one data:Front = RearFor the CQ to be full:Condition 1: Front =0 and Rear =max-1ORCondition 2:Front = rear +1 Algorithm for inserting

8、 data in a Queue (as a circular queue/array):1. If (Front =0 AND Rear = Max-1) OR front=rear+1display “queue full”exit2. if front = -1 / Q is emptyfront=0rear=0goto step5/ insert the 1st data in the CQ3. if rear =max-1 set rear = 0goto step54. rear = rear+15. Queue rear = newdataAlgorithm for deleti

9、ng data in a Queue (as a circular queue/array):1. If Front = -1 / no data in the Qdisplay “queue empty”exit2. If front = rear / there is only one data in the CQueuefront =-1rear=-1exit3. if Front = max-1 / deleting the data from the last index position of the circular arrayfront=0exit4. front=front+

10、1Implementation of a QUEUE as a linked list :If the queue is empty : front = rear =nullIf there is only one node : front =rearQueue Overflow: This condition cannot arise in a Linked List as there is no size limit.Exception : Memory runs out there is no enough space in the memory to store the data Qu

11、eue Underflow: to avoid this situation always check for Front=Null (which means the list is empty)Algorithm for inserting a new data in a queue which is a Linked list/ Linked Queue: The newnode will always be inserted in the end of the linked list as a last node!1. create newnode2. newnode.data=data

12、3. newnode.next=null4. if front =null / if the queue is empty front = newnode rear =newnode5. rear.next=newnode6. rear=newnodeAlgorithm for deleting a data from the queue as a Linked list/Linked Queue: always begins from the 1st node of the list1. if front = null / the queue is emptydisplay “ queue empty”exit2. if front = rear / there is only one nodefront = rear = nullexit3. current = front4. front=current.next5. release current

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2