The problems of overflow can be dealt with to some extent by using such modifications. Another modification is circular queue in which rear and front are joined. In this case, some items are assigned with higher priority than others and even above the item that should be removed as per the rules. One of the most popular is Priority Queue. Various modifications are possible in cases of queues. ![]() On retrieval from the queue a “front” is implemented. Every time a new value is added in a queue a “rear” is incremented. A queue is also implemented with an array however in this case two variables called “rear” and “front” keep track of the queue. This operation is called a “push” operation. This variable is generally called “tos” (top of stack) and is initiated with a value -1 and is incremented every time a new entry comes into stack. The implementation of stacks can be achieved by simply using an array and a variable that keeps track of the top of the stack. For example, the back button on your browser which takes you to previously opened links is but a simple application of a stack. We can see many applications of stacks in our daily lives. ![]() LIFO on the other hand stands for Last in First Out. We can encounter queues in many real life situations such as movie ticket counter, vehicles stopped on a traffic signal and so on. It is nothing but a queue in which the item that enters first, leaves before any other does.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |