1.2.3 • Published 2 years ago

@vimal_madhavan/queue-client v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

findTopN using priority queue( min-heap )

Run time & Space complexity

Time Complexity : O(NlogM) Space Complexity: O(N)

If 'M' represents the number of top items to be returned and 'N' represents the size of the input list, then,

'enqueue' operation for each element takes O(logM) times. Worst case is N times. 'printQueue' operation takes O(M) using stack.

Space required is O(M) for building priority queue using min-heap. O(N) is required for stack.

Quick start

Run following commands in the root directory of the project:

npm ci

npm test

API usage example

import { PriorityQueue, QueueClient } from '@vimal_madhavan/queue-client';
const queueClient = new QueueClient(new PriorityQueue());
try {
  const topN = queueClient?.findTopN([1, 2, 5, 3, 4], 2);
} catch(e) {
  const errorMessage = (e as Error).message;
  //handle errorMessage here
}

Additionally, following npm commands are available:

"build" : generate node compatiable (commonjs) es5 output,
"format": format using prettier,
"lint": checks for linting errors/warnings. uses eslint - airbnb,
"lint:fix": fixes possible linting issues,
"test": run tests,
"coverage": generate code coverage
"prepare": setup husky for git pre-commit hooks

NPM package

https://www.npmjs.com/package/@vimal_madhavan/queue-client

License

MIT

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago