The Wayback Machine - https://web.archive.org/web/20200522071542/https://github.com/TheAlgorithms/Java/issues/973
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

SingleLinkedlist.insertNth will get a infinite loop when insert a node at the end of list #973

Open
lujianmei opened this issue Oct 6, 2019 · 2 comments

Comments

@lujianmei
Copy link

@lujianmei lujianmei commented Oct 6, 2019

As titled.

` public static void main(String args[]) {
SinglyLinkedList myList = new SinglyLinkedList();

    assert myList.isEmpty();

    myList.insertHead(5);
    myList.insertHead(7);
    myList.insertHead(10);

    myList.display(); // 10 -> 7 -> 5

    myList.deleteHead();

    myList.display(); // 7 -> 5

    myList.insertNth(11, 0);

    myList.display(); // 7 -> 5 -> 11

    myList.insertNth(13, 2);

    myList.display(); // 7 -> 5 -> 11 -> 13

    myList.deleteNth(1);

    myList.display(); // 7-> 11

}`
@bw-space
Copy link

@bw-space bw-space commented Oct 14, 2019

Can you explain clearly, where are we getting an infinite loop?

@Abuubkar
Copy link

@Abuubkar Abuubkar commented Nov 17, 2019

not getting inifite loop when inserting at end using "SingleLinkedlist.insertNth"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.