Question: in java Insert a node at a specific position in a linked list. Write a method that inserts a node at a specific position of

in java Insert a node at a specific position in a linked list.

Write a method that inserts a node at a specific position of the singly linked list. A position of 0 indicates head, a position of 1 indicates one node away from the head and so on. The head node may be null meaning that the initial list is empty.

As an example, if your list starts as 1 -> 2 - > 3 and you want to insert a node at position 2 with element = 4, your new list should be 1->2->4->3

Public void insertAtPos( E e, int position)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!