Question

Show that using a single bit to store each vertex color suffices by arguing that the...

Show that using a single bit to store each vertex color suffices by arguing that the BFS procedure would produce the same result if line 18 were removed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The algorithm uses 3 different colors to denote different stages of the vertices during BFS.

Each color has a specific meaning, given below:

  • a.color[u] = WHITE- for the "undiscovered" state,
  • b.color [u] = GRAY- for the "discovered but not fully explored" state, and
  • c.color [u] = BLACK- for the "fully explored" state.

The algorithm checks for the color of the vertex before proceeding further i.e. it checks whether the vertex is discovered by the algorithm or not.

This is to avoid repeating the same vertex as we go.

Leaving off line 18, would clearly have no effect on the algorithm because nothing in the algorithm checks for the color BLACK. At the point of line 18, u has color GRAY i.e. it’s not fully explored but its discovered by BFS.

Hence, BFS procedure would produce the same result if line 18 were removed.

Add a comment
Know the answer?
Add Answer to:
Show that using a single bit to store each vertex color suffices by arguing that the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT