priorityQueue does not poll out as expected

Open
#1,070 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

Start by locating the PriorityQueue implementation and the test represented in the issue body. Reproduce the shown sequence of add and poll calls, then verify that polling returns 1, 2, 3, 4 in order and that the relevant test passes.

Written by the indexing model from the issue text.

Description

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);
  });
});

now it poll out 1, 4, 3, 2 , expected: 1,2,3,4

Dominant language
JavaScript
Stars
197k
Forks
31k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from trekhleb/javascript-algorithms

All issues in trekhleb/javascript-algorithms

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.