• Support PF! Buy your school textbooks, materials and every day products Here!

Discrete Math Questions

  • #1
I have two problems that I am having a little trouble with. Thanks in advance.

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.
 

Answers and Replies

Related Threads on Discrete Math Questions

  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
1
Views
881
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
6
Views
1K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
0
Views
811
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
5
Views
1K
  • Last Post
Replies
15
Views
2K
  • Last Post
Replies
1
Views
1K
Top