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

Branches - Michaela #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

michaela260
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

I'm pretty sure this works, but it's not doing a BFS, but rather something closer resembling a DFS traversal. See my note below.

i += 1
end

until queue.empty? && unchecked_vertices.empty?

Choose a reason for hiding this comment

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

Nice that you have this loop to make sure you hit all the vertices.

Comment on lines +49 to +54
def remove_first_from_queue(list)
temp = list[-1]
list[-1] = list[0]
list[0] = temp

return list.pop()

Choose a reason for hiding this comment

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

Clever way to remove the last from the queue, but remember that now the formerly last element is now the front of the queue.

So like if the queue was:

[3, 5, 27, 15]

After your remove_first_from_queue

[15, 5, 27]

So the next time you remove something from the front of the queue, you'll get 15... which isn't really queue-like.

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