You don't. Queues are a first in, first out structure, specifically used to process incoming data in the same order it arrives. If you want to sort a data sequence then use an array or a list.
Not to be pedantic, but if you merge and sort one queue into another queue then it is no longer a queue (first in, first out). The result is a sorted list. Regardless, there are a number of ways to merge and sort.
If both queues can themselves be sorted, then you can simply sort them and then traverse both queues simultaneously, extracting the smaller node of the two and inserting it into a new list. Continue in this fashion until both queues are empty.
If the queues cannot be sorted individually, create a temporary one-dimensional array of pointers to the data type, with enough elements to accommodate all nodes from both queues. Then traverse each queue and sequentially update the array with the data pointers. Then sort the array (do not compare pointers, compare what they point at, via indirection). Once the array is sorted, you can instantiate a new list and sequentially copy data indirectly from the array pointers. Note that both queues must remain constant during this entire process. Once the new, sorted list is built, you can delete the temporary array (but do not delete the pointers in the array).
Alternatively, if you have a list that can itself be sorted, you can forego using an array and simply copy data from the queues directly into the list, and then sort the list.
Data Mining in C++
quick sort am i correct?
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
Ready queue contain all the jobs that are ready to execute.so the job queue and the ready queue are one and the same.
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. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )
What is the difference between linear and circular queue? In: http://wiki.answers.com/Q/FAQ/2545-37 [Edit categories]The Queue by Default is Linear, it would be termed as Circular if the Last Element of the Queue pointsto the first element of the List
quick sort am i correct?
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
Queue is a data structure which is based on FIFO that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )
circular queue
Queues is the plural of queue.
Ready queue contain all the jobs that are ready to execute.so the job queue and the ready queue are one and the same.
He added the download to the queue.(Line)I saw a queue in the park(waiting line)
What is linear queue
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. A priority queue is a queue in which each element is inserted or deleted on the basis of their priority. A higher priority element is added first before any lower priority element. If in case priority of two element is same then they are added to the queue on FCFS basis (first come first serve).
The noun 'queue' is a collective noun for a 'queue of people'.
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. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )
Queue or Q (as in waiting in a queue or the letter Q)