Solved

# analysis of algoritm

Posted on 2004-11-11
202 Views
P1. Write down a computer program to compute the values of the following group of functions:

a)   f(n)=lg100 (n)          b)         f(n)=20*n3      c)f(n)=lglglg(n)=lg(3) (n)
g(n)=n0.05                       g(n)=(1.01) n              g(n)=lg* (n))

Note that, the domain of f(n) and g(n) are positive natural numbers; n=1,2,3,… . You will compute and display the values f(n) and g(n); and your program will terminate when one of the functions becomes greater than the other for five consecutive n values.

i dont understand what he means at the last sentence. " when one of the functions becomes greater than the other for five consecutive n values."

can anybody help me to understand the problem ?
0
Question by:xinex

LVL 6

Expert Comment

I believe it means this:
one of those functions returns a value that is greater than the other five for a certain n. When that same function returns a value that is greater than the other five for n+1, n+2, n+3 and n+4, the program should terminate.

HTH,
Ruud
0

Author Comment

can you explain more,
if its possible can you write the  if statment for this condition
0

LVL 6

Expert Comment

Made a typo in my first post: 'other five' should be just 'other'.

You start at n = 1, Then you go n = n + 1. Sooner or later you'll have 5 n's in a row (e.g. 6,7,8,9,10 or 40,41,42,43,44) where f(n) is greater than g(n). Or 5 n's where g(n) is greater than f(n).

Good luck writing that program. Is it homework?

0

Author Comment

yes lab. homework

i write small program,

int main( int argc, char *argv[]){

int i = 1;

/* Preliminary 1 - a */
printf("Preliminary 1\n");

while( i <= 20 ){
printf("%d\n",i);
printf("a-) %.2f %.2f\n",pow(log10(i),100),pow(i,0.05));
printf("b-) %.2f %.2f\n",20*pow(i,3),pow(1.01,i));
printf("c-) %.2f %.2f\n",pow(log10(i),3),log(i));

printf("\n");
i+=1;
}

return 0;
}

from the output can you explain which value is satisfy

Preliminary 1
a-) 0.00 1.00
b-) 20.00 1.01
c-) 0.00 0.00

a-) 0.00 1.04
b-) 160.00 1.02
c-) 0.03 0.69

a-) 0.00 1.06
b-) 540.00 1.03
c-) 0.11 1.10

a-) 0.00 1.07
b-) 1280.00 1.04
c-) 0.22 1.39

a-) 0.00 1.08
b-) 2500.00 1.05
c-) 0.34 1.61

a-) 0.00 1.09
b-) 4320.00 1.06
c-) 0.47 1.79

a-) 0.00 1.10
b-) 6860.00 1.07
c-) 0.60 1.95

a-) 0.00 1.11
b-) 10240.00 1.08
c-) 0.74 2.08

a-) 0.01 1.12
b-) 14580.00 1.09
c-) 0.87 2.20

a-) 1.00 1.12
b-) 20000.00 1.10
c-) 1.00 2.30

a-) 57.74 1.13
b-) 26620.00 1.12
c-) 1.13 2.40

a-) 2039.10 1.13
b-) 34560.00 1.13
c-) 1.26 2.48

a-) 48563.57 1.14
b-) 43940.00 1.14
c-) 1.38 2.56

a-) 838134.28 1.14
b-) 54880.00 1.15
c-) 1.51 2.64

a-) 11068842.87 1.14
b-) 67500.00 1.16
c-) 1.63 2.71

a-) 116674612.55 1.15
b-) 81920.00 1.17
c-) 1.75 2.77

a-) 1014749836.62 1.15
b-) 98260.00 1.18
c-) 1.86 2.83

a-) 7478278499.90 1.16
b-) 116640.00 1.20
c-) 1.98 2.89

a-) 47718520380.19 1.16
b-) 137180.00 1.21
c-) 2.09 2.94

a-) 268368134667.23 1.16
b-) 160000.00 1.22
c-) 2.20 3.00

(20 iteration)
0

LVL 6

Accepted Solution

> from the output can you explain which value is satisfy
Can you?

If you cannot tell whether the output is correct or not, my guess is you don't fully understand the question yet.
Just say so. I'll be happy to try another explanation.

0

## Featured Post

### Suggested Solutions

zeroFront challenge 7 58
Order table with macro 3 65
for loop with Set 4 37
Using YubiKey with REST API application 2 52
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…