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.
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.
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.In this tutorial, We are going to learn about bubble sort algorithm and their implementation in various programming languages.
In this tutorial, we are going to cover following things
- What is Bubble Sort?
- Bubble sort algorithm & it’s time complexity
- Bubble sort program in C & C++
- Java program to implement Bubble sort
- Bubble sort implementation in PHP
What is Bubble Sort?
Bubble sort is a sorting algorithm, It works by comparing each pair of adjacent elements and switching their positions if necessary. It repeats this process until all the elements are sorted.