-
Notifications
You must be signed in to change notification settings - Fork 20k
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
Djikstra optimized #933
Conversation
q.add(sv); | ||
int n=edges.length; | ||
visited[sv]=true; | ||
String s=new String(); |
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.
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.
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 have requested some changes, please go through my comments.
@@ -0,0 +1,46 @@ | |||
import java.util.*; | |||
|
|||
public class DFS { |
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.
Please make separate PRs for unrelated codes.
@@ -0,0 +1,47 @@ | |||
import java.util.*; | |||
|
|||
public class BFSs { |
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.
Please make separate PRs for unrelated codes.
return min; | ||
} | ||
|
||
public static void main(String[] args) { |
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.
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.
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. |
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! |
As of errors stated in #560 . The issue related solved with code optimization