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

I don't know if this comment is the proper way to ask a question, but here it goes: shouldn't we update (head.prev).next to the new Node? #34

Open
daniel-rios opened this issue Sep 20, 2019 · 5 comments
Assignees

Comments

@williamfiset
Copy link
Owner

Yes, something seems to be missing? Haven't touched this code in a while. What I think should happen is that the current head's prev pointer should point to the new node, and the new node's next pointer should point to the current head. Then update the head pointer to be the new node. I'm surprised tests haven't caught this.

If you're up for it, can you update the code with the proper functionality and add test(s)?
Also, FYI this repo was moved to the Algorithms repository so the current file to edit would be:

https://github.com/williamfiset/algorithms/blob/master/com/williamfiset/algorithms/datastructures/linkedlist/DoublyLinkedList.java

and the tests are at:

https://github.com/williamfiset/Algorithms/blob/master/javatests/com/williamfiset/algorithms/datastructures/linkedlist/LinkedListTest.java

@iamjoross
Copy link

@williamfiset , What is the status of this issue? I can update and test it out if you want.

@skill-bit
Copy link

I also got the impression that is something wrong at the first look. After taking a closer, everything seems to be correct.

Please check the previous line of code (line 79) and the constructor parameters of the new node.

For a reference:

      head.prev = new Node<T>(elem, null, **head**);
      head = head.prev;

@prashantkumar-cmd
Copy link

@williamfiset
What is the status of this issue? I can update

@virallalakia
Copy link

As @skill-bit mentioned in above comment, there doesn't seem any issue with the current implementation.

It seems that this can be closed as 'Invalid'. @williamfiset, what do you think?

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

No branches or pull requests

6 participants