Tag Archives: Divide & Conquer - Page 2

Merge sort c++ algorithm

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 …

Read more »

Logn 2 Dimensional Array Binary Search

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 …

Read more »

Two Dimensional Array Binary Search

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 …

Read more »

Modified binary search

Given a sorted array of (n) integers that has been rotated an unknown number of times. Give a log(n) algorithm that finds an element in the array. Assume the array has no duplicates.

Read more »

Array shuffle Java

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 …

Read more »

Maximum contiguous subsequence sum C++

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, …

Read more »

Greatest common factor calculator

Greatest common factor problem Given two integers A less than B. Write code to find the greatest common divisor between A and B commonly known as GCD. What is a greatest common factor GCD(A, B) is the largest positive integer …

Read more »

Page 2 of 212