Class Median
java.lang.Object
topics.divideconquer.Median
//DIVIDE AND CONQUER PROBLEM: THE MEDIAN OF n ELEMENTS
- Author:
- vicegd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintmedian1(int[] v) This method sorts the vector O(nlogn) and then it is a very basic operation O(1), so its calculation is O(nlogn) + O(1) - O(nlogn)intmedian2(int[] v) This method is recursive and is based on the concept of partition seen for the Quicksort algorithm.
-
Constructor Details
-
Median
public Median()
-
-
Method Details
-
median1
public int median1(int[] v) This method sorts the vector O(nlogn) and then it is a very basic operation O(1), so its calculation is O(nlogn) + O(1) - O(nlogn)- Parameters:
v- Array to calculate the median- Returns:
- Median value in the array
-
median2
public int median2(int[] v) This method is recursive and is based on the concept of partition seen for the Quicksort algorithm. It is DandC by division with a=1, b=2, k=1 - O(n)- Parameters:
v- Array to calculate the median- Returns:
- Median value in the array
-