title

4.4 Circular Queue in Data Structure | Circular Queue using Arrays in C | DSA Tutorials

description

In this lecture I have described circular queue implementation using arrays as well as analyzed the drawback of Linear Queue. I have written C program for implementation of queue using arrays.
DSA Full Course: https: https://www.youtube.com/playlist?list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU
******************************************
See Complete Playlists:
C Programming Course: https://www.youtube.com/playlist?list=PLdo5W4Nhv31a8UcMN9-35ghv8qyFWD9_S
C++ Programming: https://www.youtube.com/playlist?list=PLdo5W4Nhv31YU5Wx1dopka58teWP9aCee
Python Full Course: https://www.youtube.com/playlist?list=PLdo5W4Nhv31bZSiqiOL5ta39vSnBxpOPT
Printing Pattern in C: https://www.youtube.com/playlist?list=PLdo5W4Nhv31Yu1igxTE2x0aeShbKtVcCy
DAA Course: https://www.youtube.com/playlist?list=PLdo5W4Nhv31ZTn2P9vF02bkb3SC8uiUUn
Placement Series: https://www.youtube.com/playlist?list=PLdo5W4Nhv31YvlDpJhvOYbM9Ap8UypgEy
Dynamic Programming: https://www.youtube.com/playlist?list=PLdo5W4Nhv31aBrJE1WS4MR9LRfbmZrAQu
Operating Systems: //www.youtube.com/playlist?list=PLdo5W4Nhv31a5ucW_S1K3-x6ztBRD-PNa
DBMS: https://www.youtube.com/playlist?list=PLdo5W4Nhv31b33kF46f9aFjoJPOkdlsRc
**********************************************
Connect & Contact Me:
Facebook: https://www.facebook.com/Jennys-Lectures-CSIT-Netjrf-316814368950701/
Quora: https://www.quora.com/profile/Jayanti-Khatri-Lamba
Instagram: https://www.instagram.com/jayantikhatrilamba/
#jennyslectures
#datastructures
#circularqueue
#ugcnet
#course

detail

{'title': '4.4 Circular Queue in Data Structure | Circular Queue using Arrays in C | DSA Tutorials', 'heatmap': [{'end': 222.706, 'start': 194.033, 'weight': 0.743}, {'end': 642.681, 'start': 612.083, 'weight': 0.885}, {'end': 1125.848, 'start': 1091.434, 'weight': 0.792}], 'summary': 'Tutorial covers circular queue implementation, optimizing linear queue, and queue operations in data structure, emphasizing efficient insertion and deletion. it also explains circular queue operations and modifications, demonstrating practical examples.', 'chapters': [{'end': 57.83, 'segs': [{'end': 57.83, 'src': 'embed', 'start': 0.469, 'weight': 0, 'content': [{'end': 6.271, 'text': 'in this lecture we are going to see what is circular queue and how to implement circular queue using arrays.', 'start': 0.469, 'duration': 5.802}, {'end': 14.515, 'text': 'see, we have already discussed how to implement a queue, or you can say a linear queue, using arrays and as well as using linked list right.', 'start': 6.271, 'duration': 8.244}, {'end': 19.196, 'text': 'so you can check out those videos in the description box, fine, or in the side button.', 'start': 14.515, 'duration': 4.681}, {'end': 27.9, 'text': 'also. now, see, in that video implementation of queue using arrays, we have discussed a major drawback of the linear queue implementation.', 'start': 19.196, 'duration': 8.704}, {'end': 35.062, 'text': 'so to overcome that drawback, this circular q concept comes into picture right.', 'start': 28.82, 'duration': 6.242}, {'end': 37.123, 'text': 'see now what is that drawback?', 'start': 35.062, 'duration': 2.061}, {'end': 40.104, 'text': 'this is what a q q concept is, what it is basically.', 'start': 37.123, 'duration': 2.981}, {'end': 47.527, 'text': 'uh, following the rule, fifo rule first in first out means insertion would be from one end, that is from the rear end i am taking.', 'start': 40.104, 'duration': 7.423}, {'end': 53.568, 'text': 'this end is rear end and this is what front and deletion would be from the front only right,', 'start': 47.527, 'duration': 6.041}, {'end': 57.83, 'text': 'and deletion and insertion is going to take order of one time complexity.', 'start': 53.568, 'duration': 4.262}], 'summary': 'Lecture on circular queue implementation using arrays, overcoming linear queue drawbacks', 'duration': 57.361, 'max_score': 0.469, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI469.jpg'}], 'start': 0.469, 'title': 'Circular queue implementation', 'summary': 'Discusses the concept of circular queue as a solution to the major drawback of linear queue implementation, enabling constant time complexity for insertion and deletion.', 'chapters': [{'end': 57.83, 'start': 0.469, 'title': 'Circular queue implementation', 'summary': 'Discusses the concept of circular queue as a solution to the major drawback of linear queue implementation, enabling constant time complexity for insertion and deletion.', 'duration': 57.361, 'highlights': ['The circular queue concept is introduced as a solution to the major drawback of linear queue implementation, ensuring constant time complexity for insertion and deletion.', 'The lecture explains the rule of FIFO (First In First Out) for insertion and deletion in a circular queue, with insertion from the rear and deletion from the front, both having a time complexity of O(1).', 'The video suggests referencing previous lectures on implementing a linear queue using arrays and linked lists for further understanding of the topic.']}], 'duration': 57.361, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI469.jpg', 'highlights': ['The circular queue concept is introduced as a solution to the major drawback of linear queue implementation, ensuring constant time complexity for insertion and deletion.', 'The lecture explains the rule of FIFO (First In First Out) for insertion and deletion in a circular queue, with insertion from the rear and deletion from the front, both having a time complexity of O(1).', 'The video suggests referencing previous lectures on implementing a linear queue using arrays and linked lists for further understanding of the topic.']}, {'end': 259.144, 'segs': [{'end': 107.966, 'src': 'embed', 'start': 80.924, 'weight': 0, 'content': [{'end': 83.886, 'text': 'that thing we have already discussed in detail in the previous video.', 'start': 80.924, 'duration': 2.962}, {'end': 86.008, 'text': 'implementation of q using arrays.', 'start': 83.886, 'duration': 2.122}, {'end': 87.809, 'text': 'you can check out that video in the side button.', 'start': 86.008, 'duration': 1.801}, {'end': 89.811, 'text': 'first of all, check out that video.', 'start': 87.809, 'duration': 2.002}, {'end': 92.033, 'text': 'then i recommend you to come to this video.', 'start': 89.811, 'duration': 2.222}, {'end': 95.035, 'text': 'fine, now, this is the queue.', 'start': 92.033, 'duration': 3.002}, {'end': 100.038, 'text': 'now again, if you call nq function, in that case it would show what the queue is full.', 'start': 95.035, 'duration': 5.003}, {'end': 102.481, 'text': 'So what is that condition?', 'start': 100.899, 'duration': 1.582}, {'end': 107.966, 'text': 'the Q full condition is what at this time front is pointing to here and rear is pointing to here.', 'start': 102.481, 'duration': 5.485}], 'summary': 'Implementation of queue using arrays, explaining q full condition.', 'duration': 27.042, 'max_score': 80.924, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI80924.jpg'}, {'end': 164.339, 'src': 'embed', 'start': 129.759, 'weight': 2, 'content': [{'end': 130.561, 'text': 'That is the condition.', 'start': 129.759, 'duration': 0.802}, {'end': 138.843, 'text': 'Now, after NQ operation, I have called DQ operation, right? Now, DQ means we are going to delete data from the front of the Q.', 'start': 131.221, 'duration': 7.622}, {'end': 140.043, 'text': 'So, this would be deleted.', 'start': 138.843, 'duration': 1.2}, {'end': 141.964, 'text': 'It means front plus plus we will do.', 'start': 140.284, 'duration': 1.68}, {'end': 144.325, 'text': 'So, it means front is pointing to here.', 'start': 142.504, 'duration': 1.821}, {'end': 150.204, 'text': 'right. it means this is the garbage value now only the data between this front and rear, this.', 'start': 145.339, 'duration': 4.865}, {'end': 152.046, 'text': 'this is now our q.', 'start': 150.204, 'duration': 1.842}, {'end': 155.67, 'text': "we don't care what garbage value lies here, because we can override this value.", 'start': 152.046, 'duration': 3.624}, {'end': 158.233, 'text': "suppose i'm deleting this right now.", 'start': 155.67, 'duration': 2.563}, {'end': 164.339, 'text': 'again, if you call nq function, in that case also it will show what the q is full.', 'start': 158.233, 'duration': 6.106}], 'summary': 'After nq operation, dq deletes data from front of q. front points to garbage value, making q accessible. nq function shows q full.', 'duration': 34.58, 'max_score': 129.759, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI129758.jpg'}, {'end': 228.764, 'src': 'heatmap', 'start': 194.033, 'weight': 1, 'content': [{'end': 205.479, 'text': 'now, what if we modify our this function in q and dq operation and after modifying something, this rear?', 'start': 194.033, 'duration': 11.446}, {'end': 208.28, 'text': 'when we do, obviously we will not do rear plus plus.', 'start': 205.479, 'duration': 2.801}, {'end': 215.843, 'text': 'when we will increment rear, then it will point to here now, if you call that nq again.', 'start': 208.28, 'duration': 7.563}, {'end': 222.706, 'text': 'in that case, now see this rear is pointing to here.', 'start': 215.843, 'duration': 6.863}, {'end': 228.764, 'text': 'at this point of time, front is equal to 2 and rear is equal to 0, Right.', 'start': 222.706, 'duration': 6.058}], 'summary': 'Modification of function impacts rear and pointers, with front=2 and rear=0.', 'duration': 34.731, 'max_score': 194.033, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI194033.jpg'}], 'start': 57.83, 'title': 'Linear queue optimization', 'summary': 'Discusses the drawbacks of a linear queue in terms of space utilization, providing an example of a queue of size five being enqueued five times, and proposes modifications to optimize queue operations and space utilization, demonstrated through insertion and deletion examples.', 'chapters': [{'end': 102.481, 'start': 57.83, 'title': 'Linear queue drawback analysis', 'summary': 'Discusses the drawback of the linear queue with an example of a queue of size five being enqueued five times, resulting in the queue being full and the condition for the queue being full being shown.', 'duration': 44.651, 'highlights': ['The chapter discusses the drawback of the linear queue with an example of a queue of size five being enqueued five times, resulting in the queue being full and the condition for the queue being full being shown.', 'In the example, the queue is specified to have a size of five, and after enqueueing five times, the queue contains the elements two, minus one, five, six, and seven.', 'The video recommends checking out the previous detailed discussion on the implementation of a queue using arrays before proceeding with the current content.']}, {'end': 259.144, 'start': 102.481, 'title': 'Optimizing linear queue operations', 'summary': 'Discusses the conditions for a queue to be full, the drawbacks of linear queue due to wasted space, and the modification of queue operations to optimize space utilization, illustrated with examples of insertion and deletion.', 'duration': 156.663, 'highlights': ['After NQ operation, if DQ is called, the front pointer increments, indicating the deletion of data from the front of the queue, and the space between the front and rear becomes the queue.', 'The condition for the queue to be full is when the rear pointer is at the maximum size minus 1, which leads to wasted space and the inability to insert data even if space is available.', 'Modifying the queue operations to increment the rear pointer without using rear++, allows for efficient utilization of space and insertion of data, resolving the wasted space issue in linear queues.']}], 'duration': 201.314, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI57830.jpg', 'highlights': ['The video recommends checking out the previous detailed discussion on the implementation of a queue using arrays before proceeding with the current content.', 'Modifying the queue operations to increment the rear pointer without using rear++, allows for efficient utilization of space and insertion of data, resolving the wasted space issue in linear queues.', 'After NQ operation, if DQ is called, the front pointer increments, indicating the deletion of data from the front of the queue, and the space between the front and rear becomes the queue.']}, {'end': 480.94, 'segs': [{'end': 294.305, 'src': 'embed', 'start': 259.144, 'weight': 2, 'content': [{'end': 262.246, 'text': 'right. but now q is full.', 'start': 259.144, 'duration': 3.102}, {'end': 266.069, 'text': 'so now that condition, the full condition, the q, is full condition.', 'start': 262.246, 'duration': 3.823}, {'end': 272.994, 'text': 'you have to modify a little bit what you will do see in this case q is full now, but rear is not four.', 'start': 266.069, 'duration': 6.925}, {'end': 274.435, 'text': 'rear is not n, minus one.', 'start': 272.994, 'duration': 1.441}, {'end': 277.057, 'text': 'rear is one and front is two.', 'start': 274.435, 'duration': 2.622}, {'end': 279.259, 'text': 'how you will write down that condition.', 'start': 277.057, 'duration': 2.202}, {'end': 285.904, 'text': 'see if you write here rear plus one.', 'start': 279.259, 'duration': 6.645}, {'end': 294.305, 'text': 'mode n means size of this q equal to equal to front.', 'start': 285.904, 'duration': 8.401}], 'summary': 'The queue is full condition, with rear as 1 and front as 2.', 'duration': 35.161, 'max_score': 259.144, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI259144.jpg'}, {'end': 372.439, 'src': 'embed', 'start': 346.049, 'weight': 1, 'content': [{'end': 351.071, 'text': 'so now in nq also, we will check if the q is empty, means both front and rear equal to minus one.', 'start': 346.049, 'duration': 5.022}, {'end': 357.993, 'text': 'in that case, after inserting data here, both front and rear would point to here we will also increase rear as well,', 'start': 351.071, 'duration': 6.922}, {'end': 360.874, 'text': 'as front means both front and rear becomes zero.', 'start': 357.993, 'duration': 2.881}, {'end': 362.675, 'text': 'this condition you have to check.', 'start': 361.434, 'duration': 1.241}, {'end': 370.358, 'text': 'so one case in nq function is what if front equal to equal to minus one and rear equal to equal to minus one,', 'start': 362.675, 'duration': 7.683}, {'end': 372.439, 'text': 'or simply you can say front equal to equal to minus one.', 'start': 370.358, 'duration': 2.081}], 'summary': 'In nq, check if q is empty, increase rear and front to 0.', 'duration': 26.39, 'max_score': 346.049, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI346049.jpg'}, {'end': 438.703, 'src': 'embed', 'start': 412.863, 'weight': 0, 'content': [{'end': 417.467, 'text': 'third case may be q is not full, but we have some element in the queue right.', 'start': 412.863, 'duration': 4.604}, {'end': 420.249, 'text': 'so now we will check for that case the queue is full.', 'start': 417.467, 'duration': 2.782}, {'end': 423.672, 'text': 'you can check that condition here also at starting, also fine.', 'start': 420.249, 'duration': 3.423}, {'end': 425.514, 'text': 'after that you can write this condition.', 'start': 423.672, 'duration': 1.842}, {'end': 426.575, 'text': "it's up to you.", 'start': 425.514, 'duration': 1.061}, {'end': 427.435, 'text': "now i'm writing.", 'start': 426.575, 'duration': 0.86}, {'end': 430.818, 'text': 'else. if now i have told you what is that condition?', 'start': 427.435, 'duration': 3.383}, {'end': 438.703, 'text': 'we will not write rear equal to equal to n, minus 1 in, as we have discussed in previous video, because this is now the circular cube like this one,', 'start': 430.818, 'duration': 7.885}], 'summary': 'Discussing conditions for the circular queue implementation.', 'duration': 25.84, 'max_score': 412.863, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI412863.jpg'}], 'start': 259.144, 'title': 'Queue operations', 'summary': 'Covers queue full condition, modification, and insertion conditions, including examples and necessary adjustments for queue operations, contributing to efficient queue management.', 'chapters': [{'end': 324.242, 'start': 259.144, 'title': 'Queue full condition and modification', 'summary': 'Discusses the condition for a full queue, explaining the need for modification and providing an example of the condition check, ultimately leading to the need for modifying the queue operation and dequeue operation coding.', 'duration': 65.098, 'highlights': ['The condition for a full queue is discussed, emphasizing the need for modification in the given scenario, such as when rear is not equal to n-1, and front is not equal to 0, illustrating the practicality of the condition with an example of rear=1 and front=2.', 'The process of modifying the condition for a full queue is highlighted, demonstrating the necessity of adapting the queue operation and dequeue operation coding to accommodate the revised condition.', 'An example is provided to illustrate the practical application of the modified condition for a full queue, showcasing the validation of the condition with specific values of rear and front within the context of the queue size.']}, {'end': 480.94, 'start': 324.242, 'title': 'Queue insertion conditions', 'summary': 'Covers the conditions for inserting elements into a queue, including checking if the queue is empty, full, or has space to insert, and the necessary adjustments for the front and rear pointers.', 'duration': 156.698, 'highlights': ['The chapter covers the conditions for inserting elements into a queue, including checking if the queue is empty, full, or has space to insert, and the necessary adjustments for the front and rear pointers. It provides a comprehensive explanation of the conditions for inserting elements into a queue, covering scenarios such as checking if the queue is empty, full, or has space to insert, and the necessary adjustments for the front and rear pointers.', 'The condition for an empty queue is when both the front and rear pointers are pointing to -1. When both front and rear are pointing to -1, it signifies that the queue is empty, and this condition remains unchanged throughout.', 'After inserting data into an initially empty queue, both the front and rear pointers are set to zero. Upon inserting data into an initially empty queue, both the front and rear pointers are set to zero, signifying the presence of data in the queue.', 'The chapter explains the scenario of the queue being full, preventing further insertion of elements. It delves into the scenario where the queue is full, preventing further insertion of elements, and the necessary checks to handle this condition.']}], 'duration': 221.796, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI259144.jpg', 'highlights': ['Covers queue full condition, modification, and insertion conditions, including examples and necessary adjustments for queue operations, contributing to efficient queue management.', 'The chapter covers the conditions for inserting elements into a queue, including checking if the queue is empty, full, or has space to insert, and the necessary adjustments for the front and rear pointers.', 'The condition for a full queue is discussed, emphasizing the need for modification in the given scenario, such as when rear is not equal to n-1, and front is not equal to 0, illustrating the practicality of the condition with an example of rear=1 and front=2.', 'The process of modifying the condition for a full queue is highlighted, demonstrating the necessity of adapting the queue operation and dequeue operation coding to accommodate the revised condition.', 'The condition for an empty queue is when both the front and rear pointers are pointing to -1. When both front and rear are pointing to -1, it signifies that the queue is empty, and this condition remains unchanged throughout.']}, {'end': 644.623, 'segs': [{'end': 563.343, 'src': 'embed', 'start': 535.707, 'weight': 1, 'content': [{'end': 542.732, 'text': '1 equal to equal to front because front is 0, but 1 is not equal to front, it means q is not full.', 'start': 535.707, 'duration': 7.025}, {'end': 545.354, 'text': 'We are not going to enter into this part, right?', 'start': 543.132, 'duration': 2.222}, {'end': 548.116, 'text': 'See this this modulo n condition.', 'start': 545.794, 'duration': 2.322}, {'end': 553.8, 'text': 'this will affect only when rear becomes 4, after that it will become 0..', 'start': 548.116, 'duration': 5.684}, {'end': 559.482, 'text': 'Otherwise same it will it will have the same effect as rear plus plus right.', 'start': 553.8, 'duration': 5.682}, {'end': 560.642, 'text': 'See I will show you.', 'start': 560.002, 'duration': 0.64}, {'end': 563.343, 'text': 'Now this condition is also not true.', 'start': 561.822, 'duration': 1.521}], 'summary': "The condition 'rear equals 4' triggers a change, otherwise 'rear plus plus' remains the same.", 'duration': 27.636, 'max_score': 535.707, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI535707.jpg'}, {'end': 644.623, 'src': 'heatmap', 'start': 612.083, 'weight': 0, 'content': [{'end': 615.706, 'text': 'if q is empty, so we cannot dequeue anything.', 'start': 612.083, 'duration': 3.623}, {'end': 617.949, 'text': 'we cannot delete the data for empty.', 'start': 615.706, 'duration': 2.243}, {'end': 620.851, 'text': 'the same condition front is equal to minus 1, rate equal to minus 1.', 'start': 617.949, 'duration': 2.902}, {'end': 622.393, 'text': 'in that case you will write here.', 'start': 620.851, 'duration': 1.542}, {'end': 623.674, 'text': 'we have written this thing.', 'start': 622.393, 'duration': 1.281}, {'end': 625.996, 'text': 'but here you will write q is empty.', 'start': 623.674, 'duration': 2.322}, {'end': 627.717, 'text': 'or you can say underflow condition.', 'start': 625.996, 'duration': 1.721}, {'end': 632.121, 'text': 'right, if this minus 1 condition, then here you will write q is empty.', 'start': 627.717, 'duration': 4.404}, {'end': 633.383, 'text': "i'm not writing this thing else.", 'start': 632.121, 'duration': 1.262}, {'end': 641.44, 'text': 'if now second case may be in the queue, we have only one element left.', 'start': 635.054, 'duration': 6.386}, {'end': 642.681, 'text': 'this thing we have already discussed.', 'start': 641.44, 'duration': 1.241}, {'end': 644.623, 'text': 'i am not going into detail.', 'start': 642.681, 'duration': 1.942}], 'summary': 'Discussion on handling empty and underflow conditions in the queue, including when front and rear both equal -1.', 'duration': 48.064, 'max_score': 612.083, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI612083.jpg'}], 'start': 480.94, 'title': 'Queue operation in data structure', 'summary': 'Explains the nq and dq operations in a queue data structure, emphasizing the process of inserting and deleting elements, managing overflow and underflow conditions, and demonstrating the use of modulo operation to control the rear index, along with conditions for checking queue status.', 'chapters': [{'end': 644.623, 'start': 480.94, 'title': 'Queue operation in data structure', 'summary': 'Explains the nq and dq operations in a queue data structure, highlighting the process of inserting and deleting elements, with emphasis on handling overflow and underflow conditions, and demonstrating the use of modulo operation to control the rear index. it also presents the conditions for checking if the queue is empty or has only one element left.', 'duration': 163.683, 'highlights': ['The chapter explains the NQ and DQ operations in a queue data structure The main focus of the transcript, covering the key operations of inserting (NQ) and deleting (DQ) elements in a queue data structure.', 'demonstrating the use of modulo operation to control the rear index Demonstrates the use of modulo operation to control the rear index, ensuring that the rear index loops back to 0 when it reaches the end of the queue, preventing overflow and maintaining the circular nature of the queue.', 'handling overflow and underflow conditions Emphasizes the importance of handling overflow and underflow conditions in the queue operations, ensuring that the queue does not exceed its maximum capacity (overflow) or attempt to dequeue from an empty queue (underflow).', 'presenting the conditions for checking if the queue is empty or has only one element left Explains the conditions for checking if the queue is empty or has only one element left, providing clarity on the scenarios where dequeue operations cannot be performed, such as in the case of an empty queue or when only one element is remaining in the queue.']}], 'duration': 163.683, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI480940.jpg', 'highlights': ['The chapter explains the NQ and DQ operations in a queue data structure The main focus of the transcript, covering the key operations of inserting (NQ) and deleting (DQ) elements in a queue data structure.', 'demonstrating the use of modulo operation to control the rear index Demonstrates the use of modulo operation to control the rear index, ensuring that the rear index loops back to 0 when it reaches the end of the queue, preventing overflow and maintaining the circular nature of the queue.', 'handling overflow and underflow conditions Emphasizes the importance of handling overflow and underflow conditions in the queue operations, ensuring that the queue does not exceed its maximum capacity (overflow) or attempt to dequeue from an empty queue (underflow).', 'presenting the conditions for checking if the queue is empty or has only one element left Explains the conditions for checking if the queue is empty or has only one element left, providing clarity on the scenarios where dequeue operations cannot be performed, such as in the case of an empty queue or when only one element is remaining in the queue.']}, {'end': 1091.434, 'segs': [{'end': 676.504, 'src': 'embed', 'start': 644.623, 'weight': 3, 'content': [{'end': 651.969, 'text': 'so if one element is there, in that case both front and rear would be pointing to that element right now.', 'start': 644.623, 'duration': 7.346}, {'end': 657.723, 'text': 'if front equal to equal to rear, Right?', 'start': 651.969, 'duration': 5.754}, {'end': 661.307, 'text': 'Suppose we have dequeued these elements.', 'start': 658.664, 'duration': 2.643}, {'end': 663.81, 'text': 'Suppose I have called 4 times dequeue.', 'start': 661.708, 'duration': 2.102}, {'end': 667.492, 'text': 'Means 4 times 1, 2, 3, 4.', 'start': 664.511, 'duration': 2.981}, {'end': 671.258, 'text': 'Now after dequeuing 4 front is pointing to here.', 'start': 667.494, 'duration': 3.764}, {'end': 673.641, 'text': 'It means we have only one element left.', 'start': 671.919, 'duration': 1.722}, {'end': 676.504, 'text': 'See both front and rear are pointing to same.', 'start': 674.261, 'duration': 2.243}], 'summary': 'After 4 dequeues, only 1 element remains with both front and rear pointers pointing to it.', 'duration': 31.881, 'max_score': 644.623, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI644623.jpg'}, {'end': 1059.093, 'src': 'embed', 'start': 1030.337, 'weight': 2, 'content': [{'end': 1032.718, 'text': 'as you can see, q is full.', 'start': 1030.337, 'duration': 2.381}, {'end': 1037.54, 'text': 'so now these are nq and dq operations in circular q.', 'start': 1032.718, 'duration': 4.822}, {'end': 1055.968, 'text': 'right, you just have to modify a little bit this condition rather than rear plus plus rather than front plus plus and the q full condition would be something like this somewhere this condition is also written something like that if this front equal to equal to rear plus 1 see,', 'start': 1037.54, 'duration': 18.428}, {'end': 1059.093, 'text': 'front is 2, rear is 1.', 'start': 1055.968, 'duration': 3.125}], 'summary': 'Circular queue has nq and dq operations with front=2 and rear=1.', 'duration': 28.756, 'max_score': 1030.337, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1030337.jpg'}, {'end': 1102.737, 'src': 'embed', 'start': 1076.964, 'weight': 0, 'content': [{'end': 1081.569, 'text': "so rather than writing two or three conditions, simply write one condition, and that's it.", 'start': 1076.964, 'duration': 4.605}, {'end': 1083.27, 'text': 'that will cover all the conditions.', 'start': 1081.569, 'duration': 1.701}, {'end': 1086.173, 'text': 'right now we will see how to display the data.', 'start': 1083.27, 'duration': 2.903}, {'end': 1091.434, 'text': 'So now I guess you remember in the previous video when we were discussing the linear queue implementation using array.', 'start': 1086.693, 'duration': 4.741}, {'end': 1100.017, 'text': 'we have discussed how the display condition we have written what for loop, i is equal to front and i less than equal to rear plus 1.', 'start': 1091.434, 'duration': 8.583}, {'end': 1102.737, 'text': 'till then we are going to print, but here we cannot write down that condition.', 'start': 1100.017, 'duration': 2.72}], 'summary': 'Demonstrating simplification in writing conditions and addressing display condition in linear queue implementation.', 'duration': 25.773, 'max_score': 1076.964, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1076964.jpg'}], 'start': 644.623, 'title': 'Circular queue operations', 'summary': 'Explains circular queue operations, covering front and rear pointers behavior, empty queue conditions, and managing the front pointer based on the number of elements. it also discusses efficient insertion and deletion using a circular array structure and emphasizes the difference from linear queue implementation.', 'chapters': [{'end': 764.785, 'start': 644.623, 'title': 'Circular queue operations', 'summary': 'Explains circular queue operations, including how front and rear pointers behave after dequeuing elements and the conditions for an empty queue, with a focus on managing the front pointer based on the number of elements in the queue.', 'duration': 120.162, 'highlights': ['After dequeuing 4 times, the front pointer is pointing to the last element, indicating only one element is left in the queue.', 'When the queue has only one element left, both the front and rear pointers should point to -1, signifying an empty queue.', 'In the case of a non-empty queue with more than one element, the front pointer should be managed as a circular queue, ensuring it points to the correct index after dequeue operations.']}, {'end': 1091.434, 'start': 764.785, 'title': 'Circular queue operations', 'summary': 'Discusses the implementation of circular queue operations including nq and dq, utilizing a circular array structure to achieve efficient insertion and deletion, emphasizing the difference from linear queue implementation.', 'duration': 326.649, 'highlights': ['The chapter explains the NQ and DQ operations in circular queue, emphasizing the use of circular array to efficiently manage queue elements.', 'The implementation of circular queue utilizes a modified condition for checking queue fullness, simplifying the process compared to linear queue implementation.', 'The discussion highlights the use of circular array to achieve a circular queue, optimizing the insertion and deletion operations for efficient queue management.', 'The chapter contrasts the circular queue implementation with the linear queue, emphasizing the efficiency and simplicity in managing queue elements using circular array structure.']}], 'duration': 446.811, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI644623.jpg', 'highlights': ['The chapter contrasts the circular queue implementation with the linear queue, emphasizing the efficiency and simplicity in managing queue elements using circular array structure.', 'The discussion highlights the use of circular array to achieve a circular queue, optimizing the insertion and deletion operations for efficient queue management.', 'The chapter explains the NQ and DQ operations in circular queue, emphasizing the use of circular array to efficiently manage queue elements.', 'After dequeuing 4 times, the front pointer is pointing to the last element, indicating only one element is left in the queue.', 'In the case of a non-empty queue with more than one element, the front pointer should be managed as a circular queue, ensuring it points to the correct index after dequeue operations.']}, {'end': 1458.239, 'segs': [{'end': 1147.171, 'src': 'heatmap', 'start': 1091.434, 'weight': 3, 'content': [{'end': 1100.017, 'text': 'we have discussed how the display condition we have written what for loop, i is equal to front and i less than equal to rear plus 1.', 'start': 1091.434, 'duration': 8.583}, {'end': 1102.737, 'text': 'till then we are going to print, but here we cannot write down that condition.', 'start': 1100.017, 'duration': 2.72}, {'end': 1114.423, 'text': 'Suppose I am taking here also i is equal to front means now i is equal to front means 2.', 'start': 1102.917, 'duration': 11.506}, {'end': 1116.664, 'text': 'or i less than rear plus 1.', 'start': 1114.423, 'duration': 2.241}, {'end': 1117.605, 'text': 'this was the condition.', 'start': 1116.664, 'duration': 0.941}, {'end': 1118.905, 'text': 'right, i guess you remember.', 'start': 1117.605, 'duration': 1.3}, {'end': 1121.606, 'text': 'so i now 2 less than rear plus 1.', 'start': 1118.905, 'duration': 2.701}, {'end': 1125.848, 'text': 'rear in this case is 1 1 plus 1, that is 2 less than 2.', 'start': 1121.606, 'duration': 4.242}, {'end': 1131.311, 'text': 'no, this condition is not true, so it will not print anything, because this is circular q.', 'start': 1125.848, 'duration': 5.463}, {'end': 1132.892, 'text': 'so we cannot write down this condition.', 'start': 1131.311, 'duration': 1.581}, {'end': 1136.053, 'text': 'you have to modify this condition also, fine.', 'start': 1132.892, 'duration': 3.161}, {'end': 1138.534, 'text': 'so now here i am writing what.', 'start': 1136.053, 'duration': 2.481}, {'end': 1144.99, 'text': 'while this i not equal to rear, Fine.', 'start': 1138.534, 'duration': 6.456}, {'end': 1147.171, 'text': 'Till then we are going to print.', 'start': 1145.89, 'duration': 1.281}], 'summary': 'The display condition for a circular queue is discussed, with the modified condition being while(i != rear).', 'duration': 55.737, 'max_score': 1091.434, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1091434.jpg'}, {'end': 1206.176, 'src': 'embed', 'start': 1178.12, 'weight': 1, 'content': [{'end': 1182.261, 'text': 'here means in circular motion and this is the condition for that thing.', 'start': 1178.12, 'duration': 4.141}, {'end': 1184.062, 'text': 'now i am taking i.', 'start': 1182.261, 'duration': 1.801}, {'end': 1190.484, 'text': 'so here in this function, after in this function you can take i and you can initialize this i with front.', 'start': 1184.062, 'duration': 6.422}, {'end': 1192.265, 'text': "now i'll show the working of this thing.", 'start': 1190.484, 'duration': 1.781}, {'end': 1194.366, 'text': 'see at starting i is equal to.', 'start': 1192.265, 'duration': 2.101}, {'end': 1196.366, 'text': 'we have taken i and i is equal to front.', 'start': 1194.366, 'duration': 2}, {'end': 1199.574, 'text': 'front is now 2, so i is 2.', 'start': 1196.366, 'duration': 3.208}, {'end': 1202.275, 'text': 'this condition is not true because q is not empty.', 'start': 1199.574, 'duration': 2.701}, {'end': 1206.176, 'text': 'fine, else now the q is, while i not equal to rear.', 'start': 1202.275, 'duration': 3.901}], 'summary': 'Demonstration of circular motion algorithm with initial condition and variable updates.', 'duration': 28.056, 'max_score': 1178.12, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1178120.jpg'}, {'end': 1399.674, 'src': 'embed', 'start': 1368.915, 'weight': 0, 'content': [{'end': 1370.436, 'text': 'See rear value is 1 now.', 'start': 1368.915, 'duration': 1.521}, {'end': 1372.457, 'text': 'So now Q of 1 would be printed.', 'start': 1370.856, 'duration': 1.601}, {'end': 1374.018, 'text': 'That is 10 would be printed.', 'start': 1372.497, 'duration': 1.521}, {'end': 1376.24, 'text': 'And I is also 1.', 'start': 1375.099, 'duration': 1.141}, {'end': 1378.101, 'text': 'So here you can also write Q of I simply.', 'start': 1376.24, 'duration': 1.861}, {'end': 1381.664, 'text': 'So this is how you can display the data of a circular Q.', 'start': 1378.421, 'duration': 3.243}, {'end': 1382.564, 'text': 'See it is not like that.', 'start': 1381.664, 'duration': 0.9}, {'end': 1384.966, 'text': 'This is the only way to write down the display function.', 'start': 1382.604, 'duration': 2.362}, {'end': 1386.567, 'text': 'Maybe using for loop.', 'start': 1385.406, 'duration': 1.161}, {'end': 1388.428, 'text': 'Maybe using some other condition here.', 'start': 1386.707, 'duration': 1.721}, {'end': 1390.149, 'text': 'Rather than writing here you can use.', 'start': 1388.448, 'duration': 1.701}, {'end': 1392.791, 'text': "If you don't want to print this value separately.", 'start': 1390.75, 'duration': 2.041}, {'end': 1394.192, 'text': 'So you can use do while loop also.', 'start': 1392.831, 'duration': 1.361}, {'end': 1399.674, 'text': 'many methods can be there to display the data fine, correctly, fine.', 'start': 1395.032, 'duration': 4.642}], 'summary': 'The circular q has a rear value of 1, leading to q of 1 being printed, including 10, and i is also 1. various methods, such as for loops and do while loops, can be used to display the data correctly.', 'duration': 30.759, 'max_score': 1368.915, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1368915.jpg'}, {'end': 1456.476, 'src': 'embed', 'start': 1427.687, 'weight': 2, 'content': [{'end': 1430.008, 'text': 'now, at this time five is there.', 'start': 1427.687, 'duration': 2.321}, {'end': 1436.251, 'text': 'so here, simply in else part, you will write printf percentage, d, q, front.', 'start': 1430.008, 'duration': 6.243}, {'end': 1439.89, 'text': "that's it.", 'start': 1439.349, 'duration': 0.541}, {'end': 1441.412, 'text': 'no need to do any increment.', 'start': 1439.89, 'duration': 1.522}, {'end': 1444.117, 'text': 'so this is same as we have discussed in the previous video.', 'start': 1441.412, 'duration': 2.705}, {'end': 1449.986, 'text': 'only difference is in nq, dq and this display operation fine.', 'start': 1444.117, 'duration': 5.869}, {'end': 1453.491, 'text': 'so this is how you can implement a circular queue using arrays.', 'start': 1449.986, 'duration': 3.505}, {'end': 1456.476, 'text': 'in next video we will see how to implement queue using stacks.', 'start': 1453.491, 'duration': 2.985}], 'summary': 'Implement circular queue using arrays, next: queue using stacks.', 'duration': 28.789, 'max_score': 1427.687, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1427687.jpg'}], 'start': 1091.434, 'title': 'Circular queue operations', 'summary': 'Discusses modifying display condition and looping in a circular queue to ensure accurate output, and explains the working of a circular queue using arrays with practical examples and incrementing logic.', 'chapters': [{'end': 1147.171, 'start': 1091.434, 'title': 'Display condition and looping', 'summary': "Discusses modifying the display condition in a circular queue to ensure proper printing while looping through the elements, emphasizing the need to adjust the condition 'i is equal to front' to 'while i not equal to rear' for accurate output.", 'duration': 55.737, 'highlights': ["The need to modify the condition 'i is equal to front' to 'while i not equal to rear' for accurate output.", 'Explanation of the condition i less than rear plus 1 and its impact on printing in a circular queue.']}, {'end': 1458.239, 'start': 1147.811, 'title': 'Circular queue working', 'summary': 'Explains the working of a circular queue using arrays, demonstrating the enqueue and display operations, with examples and incrementing logic, presenting a practical approach to implement a circular queue.', 'duration': 310.428, 'highlights': ['The chapter explains the working of a circular queue using arrays, demonstrating the enqueue and display operations, with examples and incrementing logic, presenting a practical approach to implement a circular queue.', "The incrementing logic for the circular queue is illustrated with examples, such as incrementing 'i' using 'i plus 1 mod n', showcasing a practical approach to navigating the circular queue.", "The process of displaying the data in a circular queue is detailed, showing the step-by-step printing of queue elements using a while loop and incrementing 'i' until all elements are displayed, providing a comprehensive understanding of the display operation."]}], 'duration': 366.805, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/dn01XST9-bI/pics/dn01XST9-bI1091434.jpg', 'highlights': ["The process of displaying the data in a circular queue is detailed, showing the step-by-step printing of queue elements using a while loop and incrementing 'i' until all elements are displayed, providing a comprehensive understanding of the display operation.", "The incrementing logic for the circular queue is illustrated with examples, such as incrementing 'i' using 'i plus 1 mod n', showcasing a practical approach to navigating the circular queue.", 'The chapter explains the working of a circular queue using arrays, demonstrating the enqueue and display operations, with examples and incrementing logic, presenting a practical approach to implement a circular queue.', "The need to modify the condition 'i is equal to front' to 'while i not equal to rear' for accurate output.", 'Explanation of the condition i less than rear plus 1 and its impact on printing in a circular queue.']}], 'highlights': ['The circular queue concept is introduced as a solution to the major drawback of linear queue implementation, ensuring constant time complexity for insertion and deletion.', 'The lecture explains the rule of FIFO (First In First Out) for insertion and deletion in a circular queue, with insertion from the rear and deletion from the front, both having a time complexity of O(1).', 'The video suggests referencing previous lectures on implementing a linear queue using arrays and linked lists for further understanding of the topic.', 'Modifying the queue operations to increment the rear pointer without using rear++, allows for efficient utilization of space and insertion of data, resolving the wasted space issue in linear queues.', 'Covers queue full condition, modification, and insertion conditions, including examples and necessary adjustments for queue operations, contributing to efficient queue management.', 'The chapter explains the NQ and DQ operations in a queue data structure The main focus of the transcript, covering the key operations of inserting (NQ) and deleting (DQ) elements in a queue data structure.', 'The chapter contrasts the circular queue implementation with the linear queue, emphasizing the efficiency and simplicity in managing queue elements using circular array structure.', "The process of displaying the data in a circular queue is detailed, showing the step-by-step printing of queue elements using a while loop and incrementing 'i' until all elements are displayed, providing a comprehensive understanding of the display operation."]}