Found 5 Articles for Divide and Conquer Algorithms

Introduction to Divide & Conquer Algorithms

Samual Sam
Updated on 30-Jul-2019 22:30:23

486 Views

The Divide and Conquer is one of the different algorithm paradigm. It has mainly three different steps − Divide − In this phase the problem is divided into some small sub-problems of same type. Conquer − Solve the sub problems recursively. Combine − Combine the answers of the sub-problems to get the final answer. In this Section We are going to cover Closest Pair Point Problem Select Peak element from 2D Array Count inversions in an array Median of two Sorted Array

Median of two sorted array

karthikeya Boyini
Updated on 16-Jun-2020 09:23:44

473 Views

Medians are the middle numbers, in other words, the median value is the middle observation in an ordered list. It corresponds to the cumulative percentage of 50%.The size of two arrays must be same, we will find the median of two separate arrays at first, then compare the separate medians to get an actual median of two lists.Input and OutputInput: Two sorted array are given. Array 1: {1, 2, 3, 6, 7} Array 2: {4, 6, 8, 10, 11} Output: The median from two array. Here the median value is 6. Merge the given lists into one. {1, 2, 3, ... Read More

Count Inversions in an array

Samual Sam
Updated on 16-Jun-2020 09:29:16

343 Views

The inversions of an array indicate; how many changes are required to convert the array into its sorted form. When an array is already sorted, it needs 0 inversions, and in another case, the number of inversions will be maximum, if the array is reversed.To solve this problem, we will follow the Merge sort approach to reduce the time complexity, and make it in Divide and Conquer algorithm.Input and OutputInput: A sequence of numbers. (1, 5, 6, 4, 20). Output: The number of inversions required to arrange the numbers into ascending order. Here the number of inversions are 2. First ... Read More

Peak Element in 2D array

karthikeya Boyini
Updated on 16-Jun-2020 09:33:16

812 Views

An item is said to be a peak element when it is greater than or equal with all four neighbor of that element. The neighbor elements are the top, bottom, left and right elements. For this problem, we will consider some bounds. The diagonal elements are not checked as neighbor elements. More than one peak element may present in a matrix, and the peak element is not necessarily the largest element in the matrix.Input and OutputInput: A matrix of different numbers. 10  8  10  10 14 13  12  11 15  9  11  11 15  9  11  21 16 17  19 ... Read More

Closest Pair of Points Problem

Samual Sam
Updated on 16-Jun-2020 09:37:05

9K+ Views

In this problem, a set of n points are given on the 2D plane. In this problem, we have to find the pair of points, whose distance is minimum.To solve this problem, we have to divide points into two halves, after that smallest distance between two points is calculated in a recursive way. Using distances from the middle line, the points are separated into some strips. We will find the smallest distance from the strip array. At first two lists are created with data points, one list will hold points which are sorted on x values, another will hold data ... Read More

1
Advertisements