### Custom Sorted Singly LinkedList(Single LinkedList) - insert Nodes in between in java

In this Data structures tutorial we will learn what is Single LinkedList in java with example and program. We will learn how to implement your own Single LinkedList in java. We will learn how to insert Node in between Singly LinkedList in java. We will also learn complexity of inserting Node in between of Singly LinkedList in java.

What is Sorted Singly LinkedList in java?
Sorted Singly Linked List is a data structure in which all the nodes are arranged in sorted manner.
We will implement sorted Singly Linked List in ascending order of its data in java.
Below we are going to implement Sorted Singly LinkedList without taking help of api’s provided by jdk.
Complexity of insertion in Sorted Singly LinkedList is O(n).

Important methods used in below sorted Singly LinkedList program/example are as follows>
insertNodeInSortedLinkedList(int data)-  Insert Node in Sorted Singly LinkedList (in between of other Nodes) in java.

Logic explanation of how to insert Node in between sorted Singly LinkedList in java with diagram>

Let’s see how we are going to insert node in Sorted Singly LinkedList:-

Here as soon as we detect the position at which node is to be inserted we make
>newNode’s next point to previous node’s next &
>previous node’s next point to newNode.

Full Program/SourceCode to insert Node in between sorted Singly LinkedList in java>

Complexity of insert Node in between sorted Singly LinkedList in java >
Best Case :    O(1), when there is no node in List and insertion is to be done at first.
or, node to be inserted is smallest of existing nodes in LinkedList(in case if
we are arranging LinkedList in ascending order.)
Average Case :  O(n)
Worst Case : O(n)

Having any doubt? or you you liked the tutorial! Please comment in below section.

1) Stacks, Queues in Data Structures in java

2) Single LinkedList implementations in Data Structures in java:-

3) Doubly LinkedList implementations in Data Structures in java:-

5) Some of the tricky and interesting Single LinkedList implementations in Data Structures in java

6) Binary tree tutorial in java >