Merge sort c++ string Given a character string in small letter case. Write a C++ function to sort the string using Merge Sort Algorithm. Merge sort c++ implementation Merge sort is a popular sorting algorithm that runs in O(nlogn). It uses divide and concur technique so it keeps dividing the input array into two halves

Problem Given a square two dimensional integer array of size (n). Both rows and columns are sorted in ascending order. Give an algorithm to search for a particular element in the array in O(Log(n)) time complexity. Assume the array has no duplicates. Solution This problem is a follow up from the previous post. Modified binary

Problem Given a square two dimensional integer array of size (n). Both rows and columns are sorted in ascending order. Write an efficient code to search for a particular element in the array. Assume the array has no duplicates. Solution A brute force solution is to loop through the entire array until we find the

Pairs with sum problem Given an array of integers A[N]. Find all pairs of integers in the array which sum to a given value (v) Solution Let us try to solve this problem using brute force approach Code for sum of pairs method Here is the code in Perl # Given value$v = 6; # Given

Array shuffle algorithm Given an array of 2n integers in the following format a1 a2 a3 ... an b1 b2 b3 ... bn. Rearrange the array as follows a1 b1 a2 b2 a3 b3 ... an bn taking into consideration the following restrictions: 1. Arrange the array in place i.e. do not use any additional

Problem Given an array of N integers. The array is expected to contain positive as well as negative numbers. Find the maximum contiguous subsequence sum (MCSS) of the array. For example the MCSS of {2, -4, 1, 2} is 3 which is the sum of the subsequence {1, 2}. A brute force approach requires 3

Maximum contiguous subsequence sum problem Given an array of N integers. The array is expected to contain positive as well as negative numbers. Find the maximum contiguous subsequence sum (MCSS) of the array. For example the MCSS of {2, -4, 1, 2} is 3 which is the sum of the subsequence {1, 2}. A brute

Fibonacci numbers problem Write a program to compute the Fibonacci sequence number of a given integer. Your algorithm must run in linear time ie O(N). What is the fibonacci sequence Definition: Fibonacci number of (N) is the sum of Fibonacci numbers of (N-1) and (N-2). In other words, the fibonacci numbers list formula: Fibonacci(N) =

List of prime numbers Write a C++ program to find the prime numbers between 100 and 10000 What is a prime number Definition: A number (N) is prime if it has no divisors except 1 and (N) Prime number calculator To check if (N) is prime we divide (N) by all numbers from 3 to

Problem If you run the following block of java code. How many times the print statement is going to execute. public class Counting { public static void main(String args) { for (int i = 0; i < 100; i++) { for (int j = 100; j > i; j--)