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

Update BFS.cpp #779

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

Conversation

Max-CoderBoi
Copy link

Key Optimizations:
Replaced list* adjLists with vector<vector> adjLists: More modern and avoids manual memory management. Replaced bool* visited with vector: Automatically manages memory and is safer. Used queue instead of list: More intuitive for BFS. Used range-based loops (for (int adjVertex : adjLists[currVertex])): More readable.

Key Optimizations:
Replaced list<int>* adjLists with vector<vector<int>> adjLists: More modern and avoids manual memory management.
Replaced bool* visited with vector<bool>: Automatically manages memory and is safer.
Used queue<int> instead of list<int>: More intuitive for BFS.
Used range-based loops (for (int adjVertex : adjLists[currVertex])): More readable.
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.

1 participant