How to Remove Duplicate Entries from Sorted Linked List using C Programming

Here we’ll see how to remove duplicate entries from sorted Linked List using C Programming. In the previous article we saw how to remove duplicate entries from a generic linked list which will work here for sorted linked list also. But we’ll see how to take advantage of the sorted list and improve the performance … Continue reading “How to Remove Duplicate Entries from Sorted Linked List using C Programming”

How to Remove Duplicate Entries from Linked List?

Here we’ll see how to write C program to remove duplicate entries from linked list. Linked list contains duplicate entries when nodes with same value appear multiple times in the list. In the above Linked list entries, 43, 24 and 5 appeared more than once. We’ll write a C program to remove these duplicate elements … Continue reading “How to Remove Duplicate Entries from Linked List?”

How to Implement Singly Linked List in C?

What is singly linked list? In computer science, linked list is a collection of data elements, also called nodes, which are connected or linked by means of pointers or references. Connected or linked means if you have access to an element, you can go to the next element. In Singly linked list the links are unidirectional. … Continue reading “How to Implement Singly Linked List in C?”

Loop in Linked List, How to Detect and Remove in C Programming?

What is loop in linked list? Loop in linked list means you can traverse the list endlessly. If you traverse a linked list with loop, you will hit all or some of the nodes again and again. We’ll see how this is possible. Consider the normal (without loop) linked list above. Head points to the … Continue reading “Loop in Linked List, How to Detect and Remove in C Programming?”

C Program to Sort Linked List without Allocating Extra Memory

We’ll first create a linked list which is not sorted, then we’ll re-arrange the list such that the list becomes sorted. Logic is simple, we’ll iterate the list for all nodes, in every iteration we’ll take the first node out of the original list and insert that node into a new list. At any point … Continue reading “C Program to Sort Linked List without Allocating Extra Memory”

Insert an Element in a Sorted Linked List

Sorted Linked List is a linked list where the elements are always sorted. Insert operation in a singly is bit tricky. You have to insert an element such a way that the list remains sorted after insertion. The insertion logic is: If the list is empty or the value of the element (to be inserted) … Continue reading “Insert an Element in a Sorted Linked List”

How to Delete a Node from Singly Linked List?

Here we’ll see how to write C program to delete a node from singly linked list. In this example, the node to be deleted will be identified by the value of the node. Logic to Delete a Node from Singly Linked List If the first node (where the head points to) matches with the value to be deleted. … Continue reading “How to Delete a Node from Singly Linked List?”

C Program to Insert Element in Linked List

Here we’ll see how to write C program to insert a new element in a singly linked list at four possible positions: at the front of the list at the end of the list before a specified element after a specified element If the linked list does not exist while inserting the new element, in … Continue reading “C Program to Insert Element in Linked List”