Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Heap] Improve top level documentation #74

Open
lorentey opened this issue Aug 7, 2021 · 0 comments
Open

[Heap] Improve top level documentation #74

lorentey opened this issue Aug 7, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation Heap Min-max heap module

Comments

@lorentey
Copy link
Member

lorentey commented Aug 7, 2021

The current API docs on Heap provide useful information about its implementation details, but the docs don't explain what a heap is and why one would want to use it. We should add an introduction that is useful for a wider audience, moving the current documentation into an 'Implementation Details' section.

Something like this would be a good start:

A collection of comparable items arranged in a way that allows efficient access to its minimal and maximal elements.

Heaps can be used to efficiently provide sorted access to items that arrive incrementally and out of order. For example, a server application may use a heap to store its queue of incoming client transactions, processing them in order of decreasing priority.

Heaps provide highly optimized implementations for the following operations:

  • insert(_:): Inserts a new element in O(log(count)) time.
  • min()/max(): Retrieve (but does not remove) the minimum/maximum item in O(1) time.
  • removeMin()/removeMax(): Remove and return the minimum/maximum item in O(log(count)) time.

<Some toy sample code illustrating these operations>

@lorentey lorentey added documentation Improvements or additions to documentation Heap Min-max heap module labels Aug 7, 2021
@lorentey lorentey changed the title [Heap] Improve documentation [Heap] Improve top level documentation Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation Heap Min-max heap module
Projects
None yet
Development

No branches or pull requests

1 participant