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

Comments
meh

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

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;
}
Comments
this is crap

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.

Edited 3 Years Ago by happygeek: fixed formatting

Comments
*clap clap*
This article has been dead for over six months. Start a new discussion instead.