If you use a doubly-linked list to implement a queue then the queue is full whenever it is not empty. However, given that a list dynamically shrinks and expands to accommodate all the elements within it, we can never really say it is full per se because its true capacity is ultimately determined by the amount of available memory and that can vary from one moment to the next.
Note that you do not need to use a doubly-linked list to implement a queue since there is no need to physically traverse a queue. We only need constant-time access to the head (for extractions) and the tail (for insertions). We still need to maintain links between the nodes, however just one link per node would suffice for this. As such, an adapted singly-linked list (also known as a forward list) would consume less memory than a doubly-linked list would. The only change we need to make is to add one pointer to keep track of the tail node.
Note also that a singly-linked list generally does not maintain a count of its elements which helps improve efficiency even further. It's usually sufficient to know if the list is empty or not empty and we can easily determine that in constant-time simply by examining the head node state; if it points to null, then the list is empty otherwise it is not empty (or "full" if you prefer). The same applies to a queue; we're usually only interested in knowing if a queue actually exists before we extract the front element, and that can only be the case if there's at least one element in the queue (i.e., the queue is not empty). The actual number of elements is rarely of any importance, but we can easily adapt a singly-linked list to accommodate a count if we really needed one.
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
Which of the following data structures can be randomly accessed giving loc?A. linked list implemented using arrayB. singly linked listC. double linked listD. both single and double linked listThe answer is A.
implement the queue ADT using an array
Queues are a first in first out structure (FIFO). This means all extractions occur at the head of the list and all insertions occur at the tail. This requires that you maintain pointers to the head and tail node to allow constant time insertion and extraction of nodes. The nodes themselves are singly linked, each pointing to the next node. The tail node always points to NULL until a new node is insert, which the tail points to. The new node then becomes the tail. When extracting a head node, its next node (which may be NULL if it is also the last node) becomes the new head of the list. If the head is NULL, the tail is also set to NULL.
The Josephus problem is a problem to locate the place for the last survivour. It shows the power of the circular linked list over the singly linked lists.
30
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
Yes it is possible to implement stack and queue using linked list
yes
A queue can use a dynamic array, or a linked list, but if using static memory, the queue becomes a circular queue because the underlaying data structure is a static circular array. This means the ends of the array are attached.
Which of the following data structures can be randomly accessed giving loc?A. linked list implemented using arrayB. singly linked listC. double linked listD. both single and double linked listThe answer is A.
circular queue
implement the queue ADT using an array
Queues are a first in first out structure (FIFO). This means all extractions occur at the head of the list and all insertions occur at the tail. This requires that you maintain pointers to the head and tail node to allow constant time insertion and extraction of nodes. The nodes themselves are singly linked, each pointing to the next node. The tail node always points to NULL until a new node is insert, which the tail points to. The new node then becomes the tail. When extracting a head node, its next node (which may be NULL if it is also the last node) becomes the new head of the list. If the head is NULL, the tail is also set to NULL.
The Josephus problem is a problem to locate the place for the last survivour. It shows the power of the circular linked list over the singly linked lists.
A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer. There are 2 conditions for queue full if queue is implemented using arrays. First condition is Front = 1 and Rear = N Second condition is Front = Rear + 1
The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer. A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion)