Cocktail Sort is a variation of Bubble sort. Cocktail Sort traverses through a given array in both directions alternatively. In order to know more about… Read More

# Category Archives: Algorithms

Given the current position of a Knight as (i, j), find the count of different possible positions visited by a knight after N moves (in… Read More

Given a complete binary tree with values indexed from 1 to N and a key K. The task is to check whether a key exists… Read More

Given a positive integer N, the task is to count the number of N-digit numbers such that the count of distinct odd and distinct even… Read More

Given two strings S1 and S2 consisting of N and M lowercase characters, the task is to construct the lexicographically largest string by repeatedly appending… Read More

Given a string S consisting of N digits, the task is to print all possible combinations of the digits of the S that is a… Read More

Given a positive integer G, the task is to find the number of values of K such that the sum of the first N numbers… Read More

Given an array arr[] consisting of (4 * N + 1) pairs of coordinates representing the coordinates of the corners of any N squares such… Read More

Given an array of pairs arr[] of size N, where the first element of the pair is the value of the pair and the second… Read More

Given two binary arrays, A[] and B[] of size N respectively, the task is to find the number of elements in array A[] that will… Read More

Given an array, arr[] of size N and an integer K, the task is to find the number of ways of selecting K array elements,… Read More

Array Of Strings To sort an array of strings in Java, we can use Arrays.sort() function. // A sample Java program to // sort an… Read More

Given an array pre[], representing the Preorder traversal of a Perfect Binary Tree consisting of N nodes, the task is to construct a Perfect Binary… Read More

Given the head of a Linked List of size N, consisting of binary integers 0s and 1s, the task is to sort the given linked… Read More