Skip to content

Chapter 13: Constant Time Lookup of Next Node#85

Open
christopher-besch wants to merge 3 commits intopllk:masterfrom
christopher-besch:patch-1
Open

Chapter 13: Constant Time Lookup of Next Node#85
christopher-besch wants to merge 3 commits intopllk:masterfrom
christopher-besch:patch-1

Conversation

@christopher-besch
Copy link

@christopher-besch christopher-besch commented Aug 10, 2021

Isn't the lookup time of the next node constant instead of logarithmic?
Current version:

Using a priority queue, the next node to be processed can be retrieved in logarithmic time.

Referring to cppreference.com:

A priority queue [...] provides constant time lookup of the largest (by default) element, at the expense of logarithmic insertion and extraction.

Referring to Page 43:

A priority queue maintains a set of elements [...] and retrieval takes O(1) time.

Referring to cppreference.com:
> A priority queue [...] provides *constant time lookup* of the largest (by default) element, at the expense of logarithmic insertion and extraction.
Referring to Page 43:
> A priority queue maintains a set of elements [...] and retrieval takes O(1) time.
@apronchenkov
Copy link

I think it depends on the interpretation of "retrieved" -- if it includes taking out the node from the queue, it's logarithmic time for heap.

Maybe the fix should be in the chapter 4, something like: "Insertion and removal take O(logn) time,
and finding the maximum takes O(1) time.

@christopher-besch
Copy link
Author

That makes sense; thanks for clearing that up for me.

I've implemented the suggested changes and replaced retrieve with lookup. What do you say?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants