## Find Middle Element of a Linked List – Java Code

In this tutorial, We are going to explain how to find middle element of a linked list in Java. This programming question is mostly asked in a technical interviews.

For example: Given a linked list, the middle element in this linked list is 8.

15 -> 9 -> 8 -> 5 -> 6 -> NULL

There are multiple approaches to solve this problem. In this tutorial, We are going to learn two approaches through which we can find middle element of a singly linked list. Also, i have also added video tutorial at the end of this tutorial.

## Delete a Node at Nth Position from Linked List

Write a program to delete a node at Nth position from Linked List. Given a linked list, we have to write a method to delete a node from Nth position.

Subscribe Our Tutorials

Program to delete a complete linked list

## Program to Delete a Linked List

Write a program to delete a linked list. Given a linked list, we have to write a code to delete a linked list.

To delete a complete linked list, traverse all the nodes of a linked list and delete one by one.

Print Middle Element of a Linked List

## How to Delete a Linked List

To delete a node one by one maintain two pointers.  The first pointer points to head and the second pointer keeps the reference to next node. So when a node is free, you can assign the reference of next node using the second pointer.

## C Program to Reverse a Linked List using Recursion

Write a c program to reverse a linked list using recursion. Given a singly linked list, we have to write a code to reverse a linked list using recursion. This question is very important in terms of interviews.

In my previous post, I have explained C program to reverse a singly linked list. In this post, We are going to write a code to reverse a linked list using recursion.  If you are not familiar with the concept of recursion then check my previous tutorial on recursion vs iteration.

The time complexity to reverse a linked list using recursion is O(n).

## C Program to Count Number of Nodes in a Linked List

Write a c program to count number of nodes in a linked list. In this tutorial, We are going to write a c code to count the number of nodes in a linked list.

## What is Linked List?

A linked list is a collection of nodes, each pointing to next node by means of a pointer. In linked list, each node consists of two parts, a data and a pointer to next node.

## An Algorithm to Count Number of Nodes in a Linked List

i) Take a count variable and initialize it to zero, count = 0.

ii) Traverse a linked list and increment a count variable.

iii) When a node points to a null, it means we reach at end of a linked list then return the value of a count variable.

## Program to Print Middle Element of a Linked List

Write a program to print middle element of a linked list. It is also the most asked question in interviews.  I assume you have a basic understanding of linked list and it’s concept.

## C Program to Reverse a Linked List

Write a C program to reverse a linked list. Given a singly linked list, we have to write a code to reverse a linked list. In this tutorial, we are going to use iterative approach to solve this problem.

## C Program to Insert a Node at the Beginning of Linked List

Write a C program to insert a node at the beginning of linked list. In this tutorial, we create a linked list and insert a new node at the beginning/head of linked list.

A Linked list is a linear data structure which consists a group of nodes and each node points to next node by means of a pointer. In Linked list, a node consists of two parts, a data and a pointer to next node.