-
Notifications
You must be signed in to change notification settings - Fork 10
2 issues in Linked List #1
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
Comments
this is in LinkedList.java |
this issue is only in java file right? Cos i remember that i tested my c files |
And seperate the java implementation and c implementation by separate folders if you can |
I have fixed the issue with the new commit, do a |
the issue is with Node head = new Node();
Node tail = new Node(); this means that the head is never null and you cant enter the if loop in line 25. since head and tail have global scope just declaring them is enough to assigning null to the object. I hope this answers your question. LinkedList.java is an elegant implementation in my opinion than the other one. Do implement some JUnit test cases for the code and push it in the repo soon. |
for this reason the constructor is also useless! |
We can improve the elgance more by using Null object pattern.. this eliminates the risk of comparing null and would have saved you from this issue in the first place... Take this is as a small exercise and implement this code with this pattern. I leave this to you. |
…ructures * 'master' of https://github.com/AlgorithmCrackers/Data-Structures: fixes #1 also the useless constructor is removed Seperation of java and c implementation Conflicts: Linked-Lists/Java/LinkedList.java
I get 0 entry by default in the linked list.
if i add 10 i get an entry of 10 , 0
insert tail is not working
i followed the same concept as insert first but it is not working
The text was updated successfully, but these errors were encountered: