• Category

    Calculate the median of an array of numbers.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • array: ArrayLike<number>

      Values to use in the calculation

    Returns number

    The median of values

    Math

    const values = [1, 2, 3];

    median(values); // 2
    • (mean:1) to calculate the mean of an array
    • mode to calculate the mode of an array
  • Category

    Calculate the median of an array of bigints.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • array: ArrayLike<bigint>

      Values to use in the calculation

    Returns bigint

    The median of values

    Math

    const values = [1n, 2n, 3n];

    median(values); // 2n
    • (mean:2) to calculate the mean of an array
    • mode to calculate the mode of an array