Overview Selection sort is the most basic way of sorting an Array. We compare each element with its subsequent elements and swap them if one is smaller than the other. Complexity The complexity of selection sort algorithm for worst case, average cases and best cases is O(n2). Selection Sort in Java Selection Sort in C language Selection Sort in C++ … [Read more...] about Selection Sort

# Algorithms

## Binary Search

What is Binary Search? Binary search is the fast method of searching for an element in an array. In this approach, we need the array in sorted order. In Binary search, we first identify the center of the array by dividing the array size by 2. Then, we compare the search element with an element present at the center of the array. If the element at center matches with the … [Read more...] about Binary Search

## Linear Search

A linear search is the simplest form of search in an array of elements. We can perform a linear search in three distinct ways based on the order of elements in an array. There can be three scenarios, elements are in ascending order, or descending order, or no order at all. If the array contains all the elements in ascending order, we'll search for the element in the … [Read more...] about Linear Search

## Palindrome Numbers

What is a Palindrome Number? Palindrome number is a number which remains same even after reversing its digits. CaseExamplesPalindrome Number121, 2332, 34543, etc.Non-Palindrome Number122, 2335, etc Palindrome Number in Java Let's print palindrome number list using a for loop. Palindrome Number in C language … [Read more...] about Palindrome Numbers

## Swap Two Numbers

In this post, we will see examples on how to swap two numbers using a temporary variable and without using a temporary variable. Imagine you have red marbles in green glass and green marbles in red glass. How do you interchange the marbles so that red marbles will be in red glass and green marbles will be in green glass? One way is to take one more empty white glass and … [Read more...] about Swap Two Numbers