Java - Linked Lists - inserting node into specific position

Price: $5 USD

Question description

I'm learning about linked lists right now. I found an example for java that places a new node into the 3rd position on a linked list, but I've only ever seen insertion into a certain spot in the middle of a list like this done using 2 additional nodes, current and previous. I've never seen anything like .getNext after another one like this. So I need someone to explain what each part of this snippet of code does and please rewrite this code using nodes current and previous so I can understand how it relates and compares.  Elem is the name given to the node being inserted and you don't have to instantiate current and previous in the rewrite. I can just assume it's already done. Please let me know if more information is needed to answer!

  elem.setNext( first.getNext().getNext());

Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1821 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors