Queue In data Structure

What is the Q to Q is an algorithm is an algorithm and simply this is a data structure first one it is algorithm second one it is a data structure to arrange the data in a particular format and third one it is a linear Data Structure nothing what arrangement of elements in a linear form one after another and next one next one it follows a rule nothing but the complete in simply mentation of a queue based on a simple rule that is first in first out first in first out right here it is how we can implement the queue right to implement the queue we can use either static array or a dynamic arrays we can implement using static array or we can use a dynamic static Aries means what is fixed inside fix it in size and here it is the size varies automatically resize virus 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 ok so this is queue implementation with the help of a static arrays we can implement and with the help of a dynamic arrays we can implement how the Q structure will be and so what all the operations we can perform on the queue for example this is a queue structure this is a cube here here we can store the elements this is simply so we can call it as the queue right so how is Q will be created for example a static declaration simply integers here it is a q and the size in a given five so file locations will be created file location and here it is so what all the operations we can perform on the cube first one we can insert element second one week and delete element and next one week and display all the elements in the queue display elements in the queue and all these operations we can perform how means what insertion operation 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 where 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 write in a queue implementation of queue in that program we must use front variable and rear variable to perform all the operations on the queue how to insert the element and how to delete the element friend always should. In location we can’t move the front value friend always Pointing that is a fixed memory location next one year initially where is also. First location services because no elements in this queue don’t forget your umbrella TNEB umbrella no elements front is Pointing andrea is also Pointing print value 0 and rear value is also zero suppose if you want to insert an element we need to insert in the rear position only what is a rare position 0 write if you want to insert use the rear variable if you want to delete use the front variable so here where variable I’m using I am storing the element supposed 10 inserting like this and it will travel and it will stay here next after insertion now rear position will change their position shift to hear nothing but where value is a one read value is a one next one next whenever you insert the element here it is 20 20 after insertion of 29 rear stop Pointing where is Pointing location value is it too next we are inserting like this 30 we are inserting it stop Pointing country and it Pointing next we are inserting 48 stop. Become 4 it is Pointing next we are inserting 50 then it stop Pointing pointing to outside location where value fine fair value fine now whenever we are trying to insert a new element into the cube write it will give one error message what is that Q is already full Q is already full because here it is a all the five elements inserted into active the size is a 5 vi element you cannot store then what operation we have to pay for me I say you go for display or you can go for deletion operation right here it is the friend if you want to delete then we should delete this one delete generally the people saying after deletion of a first element front we should give 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 and that is not possible think generally for example in a line here it is a ticket counter is there just consider ticket counter the first person got the ticket and the person come out of the line then remaining people will move in the same way of reminding 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 light we need to shift then automatically the rear also right here it is 20 come to hear it come to hear 40 year 50 year now now the rain is pointing out only next where is Pointing where is Pointing is now Pointing because we have to decrease the real value because we are deleting an element from the queue automatically allocation 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 override the information so that’s why here it is 20 elements are overwritten 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 Rain position by that time 50 will be replaced with some other value 60 that is replacing the information you can’t delete the information which is inside the Q not only inside the cube inside the memory location in any programming language you know that basics right here it is now there is always again. Like that suppose if you are deleting continuously 20 we are deleting then rear become 431 hair becomes 340 we are deleting rare become 250 we are deleting rare become 160 we are deleting hair becomes zero hair becomes zero all the elements be inserted all the elements be deleted now front value is zero Andrea value is zero what is the meaning whenever front and rear both are equal to zero that is what we called queue is empty no elements in the beginning also whenever you created the node by the time no elements were inserted by that time also initially front is pointing to where is pointing to station whenever both the values are same that we can call it as it clearly right front and rear = 0 means queue is empty queue is empty 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 write all these things again this is all about theoretical concept of a queue implementation and annexation will see how to implement programmatically this Q thank you for watching for more videos please subscribe to Naresh additional

Speak Your Mind

*