Skip to content

Djikstra optimized #933

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

Closed
wants to merge 3 commits into from
Closed

Conversation

vishnoitanuj
Copy link

As of errors stated in #560 . The issue related solved with code optimization

q.add(sv);
int n=edges.length;
visited[sv]=true;
String s=new String();

Choose a reason for hiding this comment

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

Our static analysis engine detects that your pull request includes a change that method invokes inefficient new String() constructor. According to the best practice, creating a new java.lang.String object using the no-argument constructor wastes memory because the object so created will be functionally indistinguishable from the empty string constant "". Java guarantees that identical string constants will be represented by the same String object. Therefore, you should just use the empty string constant directly.

Copy link

@prashantdoshi28 prashantdoshi28 left a comment

Choose a reason for hiding this comment

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

I have requested some changes, please go through my comments.

@@ -0,0 +1,46 @@
import java.util.*;

public class DFS {

Choose a reason for hiding this comment

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

Please make separate PRs for unrelated codes.

@@ -0,0 +1,47 @@
import java.util.*;

public class BFSs {

Choose a reason for hiding this comment

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

Please make separate PRs for unrelated codes.

return min;
}

public static void main(String[] args) {

Choose a reason for hiding this comment

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

Try not to use this approach of having

public static void main(String[] args) {...}

call your actual method.

Instead create your class while keeping in mind of how others will use this i.e. by creating objects and calling your actual methods. So make your methods

public <return-type> methodName()

Please make this changes.

@stale
Copy link

stale bot commented Jul 8, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 8, 2021
@github-actions
Copy link

Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

@github-actions github-actions bot closed this Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants