On 10/29/11, praveen raj <[email protected]> wrote: > Priority Queue: > when popped ... returns the max priority element.... and if the priorities > of two or more elements are same...then they will popped as they are > inserted ...... > when pushed the element : puts the element in the list.... according to the > priority... > > > For making priority queue into Queue:: > on popping : make priority of every element same... so on popping... the > element...(popped according to which they are inserted....).... > on pushing : insert the element as same priority as other inserted > elements.... > > For making priority queue into stack..: > make priority of elements in increasing order... .. so on popping the > element... will pop the topmost element(with the highest priority > value)...... > on pushing the element... push the element... with the priority value more > than.... topmost priority value....... > > With regards, > > Praveen Raj > DCE-IT 3rd yr > 9999735993 > [email protected] > > > > On Thu, Sep 15, 2011 at 6:37 PM, Yogesh Yadav <[email protected]> wrote: > >> For Stack: >> >> just make a structure: >> >> struct stack_with_priorityqueue >> { >> int num; >> int priority; >> struct stack_with_priorityqueue *ptr; >> } >> >> now when we add another number just increase the priority... >> priority++.... >> >> >> For Queue: >> >> do same...just decrease priority...priority--.... >> >> >> >> ... >> >> >> On Wed, Sep 14, 2011 at 4:41 PM, bharatkumar bagana < >> [email protected]> wrote: >> >>> The well known examples of priority queue is minheap and maxheap.. >>> i guess the question is how do we implement one of these(at least) using >>> queue? >>> >>> >>> On Wed, Sep 14, 2011 at 9:08 AM, Ankuj Gupta <[email protected]> wrote: >>> >>>> I guess the functionality of priority should be maintained >>>> >>>> On Sep 13, 11:59 pm, Ankur Garg <[email protected]> wrote: >>>> > But dude are u saying stack will be implemented as a map with >>>> > <value,priority> >>>> > >>>> > and then choose element based on priority ? >>>> > >>>> > regards >>>> > Ankur >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > On Tue, Sep 13, 2011 at 10:16 PM, Ankuj Gupta <[email protected]> >>>> wrote: >>>> > >>>> > > For stack :- Keep incrementing the priority of each pushed element. >>>> So >>>> > > the last pushed element will have the greatest priority and the >>>> > > element pushed first will have >>>> > > lowest priority. >>>> > > For queue:- keep decrementing the priority of each inserted element. >>>> > >>>> > > On Sep 13, 1:45 am, Ankur Garg <[email protected]> wrote: >>>> > > > How to Implement a Queue with a Priority Queue >>>> > > > Similarly how woud you implement Stack with Priority Queue >>>> > >>>> > > -- >>>> > > You received this message because you are subscribed to the Google >>>> Groups >>>> > > "Algorithm Geeks" group. >>>> > > To post to this group, send email to [email protected]. >>>> > > To unsubscribe from this group, send email to >>>> > > [email protected]. >>>> > > For more options, visit this group at >>>> > >http://groups.google.com/group/algogeeks?hl=en. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups >>>> "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>>> >>> >>> >>> -- >>> >>> **Please do not print this e-mail until urgent requirement. Go Green!! >>> Save Papers <=> Save Trees >>> *BharatKumar Bagana* >>> **http://www.google.com/profiles/bagana.bharatkumar<http://www.google.com/profiles/bagana.bharatkumar> >>> * >>> Mobile +91 8056127652* >>> <[email protected]> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > >
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
