|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--Opus5.Example
Various example methods.
| Constructor Summary | |
Example()
|
|
| Method Summary | |
static int |
binarySearch(Comparable[] array,
Comparable target,
int i,
int n)
Returns the position of an integer in a specified contiguous region in a sorted array of integers. |
static int |
binom(int n,
int m)
Returns the binomial coefficient, |
static void |
bucketSort(int[] a,
int m)
Sorts (in place) an array of integers which are known to fall in the interval [0,m-1]. |
static int |
factorial(int n)
Returns the factorial of |
static int |
fibonacci(int n)
Returns the |
static int |
fibonacci(int n,
int k)
Returns the |
static int |
fibonacci2(int n)
Returns the |
static int |
fibonacci3(int n)
Returns the |
static int |
findMaximum(int[] a)
Returns the largest integer in an array of |
static double |
gamma()
Approximates Euler's constant. |
static int |
geometricSeriesSum(int x,
int n)
Computes the sum the first |
static int |
geometricSeriesSum2(int x,
int n)
Computes the sum the first |
static int |
geometricSeriesSum3(int x,
int n)
Computes the sum the first |
static int |
horner(int[] a,
int n,
int x)
Evaluates a polynomial in |
static int |
horner2(int[] a,
int n,
int x)
Evaluates a polynomial in |
static void |
mergeSort(Comparable[] array,
int i,
int n)
Sorts (in place) a contiguous region in array of Comparable objects. |
static void |
one()
Simple method to illustrate parameter passing with primitive types. |
static void |
one2()
Simple method to illustrate parameter passing with reference types. |
static double |
pi(int trials)
Computes the value of pi. |
static int |
power(int x,
int n)
Returns |
static void |
prefixSums(int[] a,
int n)
Computes (in place) all the prefix sums of an array of |
static int |
sum(int n)
Returns the sum of the first |
static void |
two(int x)
Simple method to illustrate parameter passing with primitive types. |
static void |
two2(Opus5.Example.Obj x)
Simple method to illustrate parameter passing with reference types. |
static void |
typeset(int[] l,
int D,
int s)
Finds the optimum way to typeset a justified paragraph. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Example()
| Method Detail |
public static int sum(int n)
n - The number of integers to sum.
public static int horner(int[] a,
int n,
int x)
a - The coefficients of the polynomial.n - The degree of the polynomial.x - The value of public static int factorial(int n)
n - The value of public static int findMaximum(int[] a)
a - The array of integers.public static double gamma()
public static int geometricSeriesSum(int x,
int n)
x - The value of n - The number of terms to be added.
public static int geometricSeriesSum2(int x,
int n)
x - The value of n - The number of terms to be added.
public static int power(int x,
int n)
x - The value of n - The value of
public static int geometricSeriesSum3(int x,
int n)
x - The value of n - The number of terms to be added.
public static int horner2(int[] a,
int n,
int x)
a - The coefficients of the polynomial.n - The degree of the polynomial.x - The value of
public static void prefixSums(int[] a,
int n)
a - The array of integers.n - The length of the array of integers.public static int fibonacci(int n)
n - The value of public static int fibonacci2(int n)
n - The value of
public static void bucketSort(int[] a,
int m)
a - The array of integers to sort.n - The length array of integers to sort.BucketSorter
public static int binarySearch(Comparable[] array,
Comparable target,
int i,
int n)
array - The array of integers.target - The target of the search.i - The left end of the region to be searched.n - The length of the region to be searched.java.lang.IllegalArgumentException - If the target is not in the array.public static int fibonacci3(int n)
n - The value of
public static void mergeSort(Comparable[] array,
int i,
int n)
array - The array of comparable objects to be sorted.i - The position of the left-most element to be sorted.n - The length of the region to be sorted.TwoWayMergeSorter
public static int fibonacci(int n,
int k)
n - The value of k - The value of
public static int binom(int n,
int m)
n - The value of m - The value of
public static void typeset(int[] l,
int D,
int s)
l - The lengths of the words in the paragraph.D - The length of a line.s - The length of the normal interword space.public static double pi(int trials)
trials - The number of trials to be done.public static void one()
public static void two(int x)
public static void one2()
public static void two2(Opus5.Example.Obj x)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||