Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

analysis of algoritm

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
xinex
Asked:
xinex
  • 3
  • 2
1 Solution
 
mosphatCommented:
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
 
xinexAuthor Commented:
can you explain more,
if its possible can you write the  if statment for this condition
0
 
mosphatCommented:
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
 
xinexAuthor Commented:
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
 
mosphatCommented:
> 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now