Skip to content

Update graph.md - use popleft() instead of pop() in the queue - Topological sort #685

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SniperBuddy101
Copy link

No description provided.

Copy link

@shardul-shah shardul-shah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangshun +1 on this PR. This is the mistake I also noticed, which we discussed earlier today, and which you agreed was a mistake.

Reasoning: Topological sort uses BFS and a queue. If we append to the back (index -1) of the queue, we should pop from the front of the queue - index 0, that is. queue.popleft() (since we use deque).

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