How to Implement Periodic and Single Shot Timers in Linux?

In our program, we often need to do some tasks repeatedly with some time interval. We can think of a simple solution of having a loop with the actual task and a sleep()..  The sleep() function can wait for some time and then we can call a function to do the task. Problem here is … Continue reading “How to Implement Periodic and Single Shot Timers in Linux?”

Detect and Remove Loop in Linked List in C

What is Loop in Linked List? In a standard singly linked list, the last node always points to NULL. If you traverse such a linked list, the traversal will end at the last node. That means you can not go anywhere from the last node. Here is an example of a standard linked list. Loop … Continue reading “Detect and Remove Loop in Linked List in C”

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”

C Program to Convert Binary Number to Decimal

Binary number system is 2-based which means at most two symbols, 0 (zero) and 1 (one), can be used to represent a binary number. Example of binary number is 110110011, sometimes binary numbers are written as 1101100112, where 2 is represented as base of the number system. Binary number system is the basis of all computer and digital systems. … Continue reading “C Program to Convert Binary Number to Decimal”

Insert an Element in a Sorted Linked List

Inserting in a sorted linked list means that the linked list will remain sorted after the insertion. So to insert a new element, we need to find out the appropriate place and insert the new node there. Logic to Insert an Element in a Sorted Linked List If head points to NULL or the new … Continue reading “Insert an Element in a Sorted Linked List”

0
0
0
0
1
0