Queue | Data Structures Tutorial | Mr.Srinivas

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to nourish technologies this is inverse so today we are going to discuss about queue data structure so what is the Q so Q is an algorithm Q is an algorithm and simply this is a data structure first one it is algorithm second one it is data structure to arrange the data in a particular format and third one it is a linear data structure nothing but arrangement of elements in a linear form one after another and next one next one it follows a rule nothing but the complete inflammation of a queue based on a simple rule that is first in first out FIFO first in first out right here it is how we can implement the queue right to implement the queue we can use either static arrays or a dynamic arrays we can implement using static arrays or we can use a dynamic arrays a static arrays means what is a fixed in size fix it in size and here it is the size varies automatically the size varies depends on the number of elements storing the size will increase and if you want to delete some of the elements the size will decrease automatically okay so this is Q implementation with the help of a static arrays we can implement and with the help of a dynamic arrays we can implement so how the Q structure will be and so what all the operations we can perform on the q see for example so this is the Q structure this is the Q here here we can store the elements this is simply so we can call it as a cue right so how ask you will be created for example a static declaration simply in teaser here it is a cue and the size we have given five so five locations will be created five locations and here it is so what all the operations we can perform on the cue first one we can insert element second one we can delete element and next one we can display all the elements in the queue display elements in the queue and all these operations we can perform how means what insertion operations deletion operations how we can insert an element into the queue and how can we delete an element from the queue simple insertions from where from rail here it is we can insert the elements and how can we delete the elements deletion from the front so these variables are mandatory these variables are mandatory whenever we are performing operations right in a queue implementation of a queue in that program we must use a front variable and rare variable to perform all the operations on the queue okay so how to insert the element and how to delete the element observe friend always should point into the first location we cannot move the front value front always pointing to the first location that is a fixed memory location and next one where initially rare is also pointing to the fore locations are wiser because no elements in this queue no elements so front is pointing to zero and the rare is also pointing to zero friend value zero and rare value is also zero suppose if you want to insert an element we need to insert in the rare position only what is a rare position zero right if you want to insert use the rare variable if you want to delete use the front variable so here rare variable I am using I am storing the element supposed 10 nothing but we are inserting like this and it will travel and it will stay here next after insertion now rare position will change rare position shift to hear nothing but rare value is a one rare value is a one next one next whenever you insert the element here it is a 20 20 after insertion of 20 now rare stop pointing to second one rare is pointing to the next location rare value is a two next we are inserting like this 30 we are inserting it stop pointing it will become three and it pointing to this one next we are inserting 40 it stop pointing rare value become 4 it is pointing to this one next we are inserting 50 then it stop pointing rare is pointing to the outside location where value 5 rare value 5 so now whenever we are trying to insert a new element into the queue right it will give 1 error message what is that q is already full q is already full because here it is a all the five elements inserted into a queue the size is a 5 so sixth element you cannot store then what operation we have to perform means either you go for display or you can go for delay an operation right here it is the friend if you want to delete it then we should delete this one delete generally the people saying after deletion of a first element front we should move to this next location that is completely wrong suppose if you move the front location directly to next next next finally it will reach that end that is not possible think generally for example in your cue line here it is a ticket counter is there just consider ticket counter so first person got the ticket and the person come out of the queue line then remaining people will move in the same way or remaining all the elements we should shift that is the process deletion of a front element is nothing but we need to shift all the elements in the queue line right we need to shift then automatically the rail also right here it is 20 come to here 30 come to here 40 here 50 here now now the rail is pointing and of course 50 will be here only next the rear is pointing to 4 red is pointing to 4 is now pointing to this one because we have to decrease the rare value because we are deleting one element from the queue so automatically a location will become empty there you can store the new value we already know that it is impossible to delete the data which is inside the memory location what we can do only we can overwrite the information so that is why here it is these elements are overridden but still in this location 50 is there then what we should do next suppose if you want to insert another element that we are inserting in the rare position by the time 50 will be replaced with to some other value 60 that is replacing the information you can't delete the information which is in inside the queue not only inside the queue inside the memory location in any programming language we know that basics right here it is now the rare is always again pointing to that next node like that so like that suppose if you are deleting continuously 20 we are deleting then we're become 430 we are deleting we're become 340 we are deleting rare become 250 we are deleting we're become 160 we are deleting we're become zero rare becomes zero nothing but all the elements we inserted all the elements we deleted now front value is zero and rare value is zero what is the meaning whenever front and rear both are equals two zeros that is what we called queue is empty no elements in the beginning also whenever you created the node by that time no elements were inserted so by the time also initially front is pointing to the first location rare is pointing to the first location whenever both the values are same that we can call it as it clearly right front and rear equals zero means queue is empty queue is empty so this is how we are inserting the elements and how we are deleting the elements how we are checking queue is full or not how we are checking queue is empty or not right all these things okay so this is all about a theoretical concept of a queue implementation okay in the next session we will see how to implement programmatically this queue thank you for watching for more videos please subscribe to narration 80 channel you
Info
Channel: Naresh i Technologies
Views: 363,569
Rating: 4.8669257 out of 5
Keywords: Data Structures, Srinivas, Naresh IT, Learn Data Structures, Hands on Data Structures Training, Data Structures Demo, Online Data Structures Training, Data Structures Tutorial Videos, Data Structures Overview, Data Structures Interview Questions
Id: gnYM_G1ILm0
Channel Id: undefined
Length: 10min 57sec (657 seconds)
Published: Tue Oct 04 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.