Find all N-digit numbers with equal sum. N varies from [1 to 9] and sum < = 81 (Maximum possible sum in a 9-digit number)
Convert a given binary tree to BST (Binary Search Tree) by keeping original structure of the binary tree intact.
Given an array where all its elements are sorted except two elements which were swapped, sort the array in linear time. Assume there are no duplicates in the array.
Implement Quicksort algorithm using Hoare’s Partitioning scheme.
Given a normal binary tree, convert it to Left-child right-sibling (LC-RS) binary tree.
Given an unsorted array of integers, find a triplet with given sum in it.
Implement your own diff utility. i.e given two similar strings, efficiently list out all differences between them.
Given a number, check if it is power of four or not.
Given M sorted lists of variable length, print them in sorted order efficiently.
Given a string, calculate its rank among all its lexicographically sorted permutations. For example, consider below lexicographically sorted permutations
Given a linked list containing 0’s, 1’s and 2’s, sort linked list by doing single traversal of it.
Given two Boolean arrays X and Y, find the length of longest continuous sequence that starts and ends at same index in both arrays and have same sum. In other words, find max(j-i+1) for every j >= i where sum of sub-array X[i, j] is equal to sum of sub-array Y[i, j].
Implement Quicksort efficiently for inputs containing many repeated elements. Quicksort exhibits poor performance for inputs that contain many repeated elements. The problem is clearly visible when all the input elements are equal. Then at each recursion, the left partition is empty (no input values are less than the pivot), and the right partition …
In this article, we will implement Ternary Search algorithm and compare its performance with Binary Search.