While working on linked data-structures, we have to create linked lists regularly. To ease that process, we can create a utility function, which creates linked list from given data and returns head of the new linked list. Our functions will accept a variable argument and it will return a Node. We are using Node class […]

## Create a Node class using java generic – for linked list

This class can not be used in any practical scenario. Because, the data part is going to be a lot different. While learning the datastructures and algorithms, this class is going to be very useful. While working on any linked datastructures, we create a class which acts as a node. And, It has following fields. […]

## Find length of a linked list using recursion

You can read about calculating length of a linked list by iterative method here. In recursion, the iterative loop or explicit loop is replaced by recursive function calls. In recursive calls, a stack is used to store values calculated during the recursion. And when stack unfolds, the recursion calls are replaced by those values. Let […]

## Find length of a linked list by iterative method

We are going to find lenght of a Linked List using iterative method. You can read the recursive method here. The simple logic to find length of a Linked list is – to increment a counter until you run out of nodes. Here is the simple algorithm. Step 1 :- Initialize a counter to 0 […]