Raihan Jamal wrote:I have updated the code. . . .
An implementation of a doubly-linked list<E> will take about two pages to print out. You will have methods like add(E), add(int, E), addAtStart(E), addAtEnd(E), remove(E), remove(int), removeFromStart(), removeFromEnd(), get(int), indexOf(E), etc.
You can’t fit all those into the space you have taken.
Implement the plain linked list.
Enhance it will other
List interface methods, eg size(), isEmpty().
Then enhance it (possibly as a subtype) with methods like nodeAt(int), insertBefore(Node, E) and insertAfter(Node, E).
Then enhance it with findInsertionPoint(E, Comparator<E>) and findInsertionPoint(E extends Comparable<? super E>). Now you have the insertion point, and you can use the methods you have got to insert there.
Now all you have to do is create a suitable Comparator<E> and you are home and dry.