Message from @Jacob
Discord ID: 506713890105720852
plugging that in to what you had before:
f(n) = 2\*(2\*f(n-2) + O(1)) + O(1) = 2\*2\*f(n-2) + O(1)
ah, so it just simplifies to another logarithmic function?
yes
its exponential (the inverse of logarithm)
Okay. That should be enough to write up a logical explanation, I think. Apparently the other two function are easier to analyze.
Thanks a lot
```java
public void three(int n)
{
int i, j, k;
for (i = n/2; i > 0; i = i/2)
for (j = 0; j < n; j++)
for (k = 0; k < n; k++)
System.out.println("i: " + i + " j: " + j+" k: " + k);
```
This is the next one. Should be easier for me to figure this one out since it's just for loops, right?
yes
```java
public static void four(int n)
{
if (n > 1)
{
System.out.println(n);
four(n-1);
}
for (int i = 0; i < n; i++)
System.out.println(i);
}
```
I'm pretty sure this one is just Nlog(N) but I might be wrong
idk I'll go try to figure this stuff out myself and come back if there's a problem
thanks
you're welcome
@ThisIsChris If there was only one call to two() rather than two calls, would that make it an O(n) function?
Since it just calls itself n times until it reaches the base case, and than calling itself twice each time
@Jacob yes
Thanks
so I guess the last function is O(n^2 log(n))
wait no
second one is O(n^2 log(n))
maybe that simplifies to something idk
@Jacob base case is f(1) = O(1)
for n > 1:
f(n) = f(n-1) + O(n)
so f(n) = sum over i from 1 to n of O(i)
sum of i from 1 to n of i = n*(n-1)/2
so f(n) = O(n^2)
^
you could also expand and see how much work is being done in each step
four(n) does a function call (O(1) not accounting for the recursion) and then prints n
if you expand that all the way, you'll see that it does n+(n-1)+(n-2)+...+2+1 print statements, which is O(n^2) as @ThisIsChris pointed out
that's another perspective that I use sometimes to calculate big Os
<@&435155896780324864> Lads, it's that time of week again
anyone online to help me with Java?
I have a program that converts infix expressions into postfix expressions. It worked for one expression, but didn't work for another. I don't know if exponents broke it or what.
false alarm guys, I figured out the problem
I’m thinking about doing freelance SEO work along with some other things in my relatively rural area working with small businesses. Anyone have experience with this sort of thing?
I do!
What do you need help with specifically?
Nothing as of yet I’m about to do up some marketing materials and try to get a couple of low risk customers to work on (car dealerships, private restaurants, etc) do you do this as work?