-
Notifications
You must be signed in to change notification settings - Fork 39
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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? |
There was a problem hiding this comment.
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.
def remove_first_from_queue(list) | ||
temp = list[-1] | ||
list[-1] = list[0] | ||
list[0] = temp | ||
|
||
return list.pop() |
There was a problem hiding this comment.
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.
No description provided.