Skip to content

Commit b0b382d

Browse files
committed
fixed typos
1 parent b21bfc9 commit b0b382d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contents/approximate_counting/code/java/ApproximateCounting.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static double increment(double v, double a) {
4141
static double approximateCount(int nItems, double a) {
4242
double v = 0;
4343

44-
for (int i = 1; i < nItems + 1; i++) {
44+
for (int i = 0; i < nItems; i++) {
4545
v = increment(v, a);
4646
}
4747

@@ -50,15 +50,15 @@ static double approximateCount(int nItems, double a) {
5050

5151
/*
5252
* This function takes
53-
* - nTrails: the number of counting trails
53+
* - nTrials: the number of counting trails
5454
* - nItems: the number of items to count
55-
* - a: a scaling value for th elogarithm based on Morris's paper
55+
* - a: a scaling value for the logarithm based on Morris's paper
5656
* - threshold: the maximum percent error allowed
5757
* It terminates the program on failure
5858
*/
59-
static void testApproximateCount(int nTrails, int nItems, double a, double threshold) {
59+
static void testApproximateCount(int nTrials, int nItems, double a, double threshold) {
6060
double avg = DoubleStream.generate(() -> approximateCount(nItems, a))
61-
.limit(nTrails)
61+
.limit(nTrials)
6262
.average()
6363
.getAsDouble();
6464

0 commit comments

Comments
 (0)