Class Mode

java.lang.Object
topics.divideconquer.Mode

public class Mode extends Object
//DIVIDE AND CONQUER PROBLEM: MODE OF n ELEMENTS
Author:
vicegd
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    mode1(int[] v, int[] mo)
    This method iteratively computes the predominant element (mode).
    void
    mode2(int[] v, int[] mo)
    This method previously orders the vector O(nlogn) and then it looks for the mode O(n).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Mode

      public Mode()
  • Method Details

    • mode1

      public void mode1(int[] v, int[] mo)
      This method iteratively computes the predominant element (mode). It is quadratic O(n^2)
      Parameters:
      v - Array used to calculate the mode
      mo - Array with the solution (value and repetitions)
    • mode2

      public void mode2(int[] v, int[] mo)
      This method previously orders the vector O(nlogn) and then it looks for the mode O(n). It is O(nlogn) + O(n) - O(nlogn). It is DandC because of the Quicksort sorting
      Parameters:
      v - Array used to calculate the mode
      mo - Array with the solution (value and repetitions)