Arrange the following list of functions in ascending order of growth rate. If the
growth rate of function f is less than the growth rate of function g, you write f < g. For
functions having the same growth rate, use = to denote this case. Your answer therefore
will be one line containing the functions and symbols < and =.

2n log n,squareroot of n, 2 pow nāˆ’4, (n + 4)(n āˆ’ 6), 2 pow
n / 2. 4n log n, n2 + 8n log n, 2n

jephthah commented: meh -2

Recommended Answers

All 7 Replies

its not even fun any more, is it.

I just want to clarify what these functions are:

1. 2 pow nāˆ’4. Is this 2 pow (n - 4) or [ 2 pow (n) ] - 4.
I suppose it's the former.

2. n2 + 8n log n. I am confused with this one. But, I suppose it is
[ n pow (2) ] + 8n log n

who cares what it is.

he didnt post any code, and we don't do people's homework.

Here it is...I hope this helps you...

#include <stdio.h>
#include <conio.h>
#include <math.h>

char printVar (int i)
{
	switch (i) {
		case 0: return 'f';
		case 1: return 'g';
		case 2: return 'h';
		case 3: return 'F';
		case 4: return 'G';
		case 5: return 'H';
		case 6: return 'L';
	}
}

void dispResult (int i, int j, int rel)
{
	printf ("%c ", printVar(i));
	if (rel < 0)
		printf ("<");
	else
		rel == 0 ? printf ("=") : printf (">");
	printf (" %c.\t", printVar(j));
}

void displayFoo ()
{
	clrscr ();
	puts ("Let f = 2n logn;  g = 2 pow (n-4);  h = (n + 4)(n - 6);");
	puts ("  F = 2 pow (n/2);  G = 4n logn;  H = npow(2) + 8nlogn;");
	puts ("  L = 2n");
}

int main ()
{
	/* In Differential Calculus, it is obvious that the greater the
	   growth rate, dr/dt, the faster that function increases in a
	   short span of time. The lesser the growth rate, the longer
	   that function increases in a span of time. */
	double fooGR[7];
	int i, j;

	displayFoo ();
	/* Let's compute the instantaneous growth rate at n = 1000. */
	fooGR[0] = 2 * 1000 * log (1000);
	fooGR[1] = pow (2, 1000 - 4);
	fooGR[2] = (1000 + 4) * (1000 - 6);
	fooGR[3] = pow (2, 1000 / 2);
	fooGR[4] = 4 * 1000 * log (1000);
	fooGR[5] = pow (1000, 2) + 8 * 1000 * log (1000);
	fooGR[6] = 2 * 1000;

	for (i = 0; i < 7; ++i) {
		for (j = 0; j < 7; ++j) {
			if (fooGR[i] > fooGR[j])
				dispResult (i, j, 1);
			else
				dispResult (i, j, (fooGR[i] == fooGR[j]) ? 0 : -1);
		}
	}

	return 0;
}
commented: this is crap -2

I'm sorry I was too late...
Not to do it again next time...
Thanks...

what's this non-standard conio.h and clrscr() crap?

why do you refuse to use code tags?

i dont know if your program works in any meaningful way, because it won't even compile

get this weak stuff out of here.

commented: *clap clap* +10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.