Given an integer n, find value of its square root. Examples : Input: n = 16 Output: 4 Input: n = 8 Output: 2 Note – floor value of 2.8 is 2. Read more →
Algorithms
6 postsThere are many fundamental and advanced sorting algorithms. All sorting algorithms are problem-specific, which means they work well on some specific problem but do not work well for all the problems. All Read more →
Merge sort is a sorting technique based on the divide and conquer technique. Recursively: split the list in half, sort each half, then merge the sorted halves together. Algorithm : MergeSort(A, p, Read more →
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. It examines all pairs of adjacent elements, swapping them when they Read more →
Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. For the 2nd, 3rd, 4th, etc. element: slide backwards into proper relative Read more →
In Selection Sort algorithm, First, find the smallest element and swap it with the first. Sort the rest of the list the same way. Algorithm : for i in 0 .. n-2 Read more →
Write a C++ program to check whether a given number is positive, negative or 0. Examples : Number = -44 Output: Negative Number = 0 Output: 0 Number = 50 Output: Positive Read more →
Algorithm is a step-by-step procedure which is used to solve a problem. It is important Computer Science and Software Engineering. We can improve our program efficiency in cost and time by choosing Read more →