Generate Prime Numbers between 1 to N – Sieve of Eratosthenes

Write an efficient program to generate prime numbers between 1 to N (Where N is 10, 100, 1000 etc). This question can also be asked like this, Generate prime numbers between 1 to 100 or 1 to 10 etc.

Suppose the value of N is 10, So the prime numbers between 1 to 10 is 2, 3, 5, 7.  Now let’s learn the most efficient algorithm (Sieve of Eratosthenes) to generate Prime Numbers between 1 to N. Before solving this program, let’s understand what is a prime number.

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.

Bubble Sort Program, Algorithm & their Time Complexity

Bubble Sort program, Algorithm & their time complexity. Write a program to implement a bubble sort algorithm. What’s the time complexity of bubble sort algorithm ?

In this tutorial, We are going to learn about bubble sort algorithm and their implementation in various programming languages.

Bubble Sort

Bubble sort algorithm work by comparing each pair of adjacent elements and switching their positions if necessary. It repeats this process until all the elements are sorted.