pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/TheAlgorithms/JavaScript/pull/1861

"https://github.githubassets.com/assets/actions-902e75f4f51a80db.css" /> added changes to your bellmanford.js by Ujwal200707 · Pull Request #1861 · TheAlgorithms/JavaScript · GitHub
Skip to content

added changes to your bellmanford.js#1861

Open
Ujwal200707 wants to merge 1 commit into
TheAlgorithms:masterfrom
Ujwal200707:master
Open

added changes to your bellmanford.js#1861
Ujwal200707 wants to merge 1 commit into
TheAlgorithms:masterfrom
Ujwal200707:master

Conversation

@Ujwal200707
Copy link
Copy Markdown

The change replaces the final loop with a direct return statement.
Previously, the code looped through all vertices to find the destination and then returned its distance. This loop was unnecessary because the destination index is already known.
By using:

return dis[dest]

the code becomes more efficient and readable.
It removes redundant iterations, reduces time complexity for that part from O(V) to O(1), and makes the function cleaner without affecting the output.

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

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy