- #1

- 426

- 0

## Homework Statement

Count the number of times the following algorithm prints "Hello", then find the "best" big-oh approximation for the number of print statements in the algorithm.

For i=1 to n

Begin

Print "Hello"

For j=1 to i

Print "Hello"

End

End

## The Attempt at a Solution

I found that

at n=1, hello 2 times

at n=2, hello 3 times

at n=3, hello 4 times

at n=4, hello 5 times

at n=5, hello 6 times...

I tried to find an equation that would follow this pattern but all the ones I could think of would work for a few times then it would go off. Is there an equation or something I can plug into this to figure it out? Don't worry about the Big-oh approximation as I can do that myself. I just need to figure out the formula. Thanks

This is the second problem.

## Homework Statement

How many different functions are there from {1,2,3,4} to {1,2,3}?

## Homework Equations

C(n,r)

P(n,r)

## The Attempt at a Solution

I'm not sure what to do in this problem or what it really is asking for. I think it might have something to do with subsets of {1,2,3} but I'm not sure. Any help is great.