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.
Program to delete a complete 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.
Write a program to reverse a linked list using recursion. Given a linked list print them in reverse order using recursion. This question is mostly asked in interviews.
In my last post, I have explained how to reverse a linked list using an iterative approach. In this post, We will learn how to reverse a linked list using recursion. The time complexity for both iterative and recursive approach is O(n).
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.
C Program to Count Number of Nodes in a Linked List
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.
Write a program to implement a stack using linked list. In my last post, I have explained the implementation of a stack data structure using an array. In this post, I’ll explain how to implement a stack data structure using 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.
Write a C, C++ program to reverse a linked list. Given a linked list, write a program to reverse a linked list. In this program, we will reverse a linked list using an iterative approach.
To insert node at the beginning of a linked list
1. Create a new node dynamically.
2. Insert a data and point the new node to the next node.
3. Put a reference of head node to the new node. So that head node points to new node.