trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
185.03k stars 29.84k forks source link

Update PriorityQueue.js #1073

Open PradeepG-07 opened 9 months ago

PradeepG-07 commented 9 months ago

Changed the default priority of a item to value of the item if the priority is not provided manually in the add() method. Now it resolves the issue #1070 describe('priorityQueue Test:', () => { it('should return correct priorityQueue results:', () => { const pq = new PriorityQueue(); pq.add(1); pq.add(2); pq.add(3); pq.add(4); expect(pq.toString()).toBe('1,2,3,4'); expect(pq.poll()).toBe(1); expect(pq.poll()).toBe(2); expect(pq.poll()).toBe(3); expect(pq.poll()).toBe(4); }); }); It polls out values as 1,2,3,4

PradeepG-07 commented 9 months ago

Hi @obafemitayor, Good to hear from you please merge the request if everything looks fine. Thank you.

obafemitayor commented 9 months ago

Hi @obafemitayor, Good to hear from you please merge the request if everything looks fine. Thank you.

@PradeepG-07 I am not sure I can though. I need to be a maintainer to do that

PradeepG-07 commented 9 months ago

Lol 😄 That's okay