1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Discrete Math Questions

  1. Oct 28, 2007 #1
    I have two problems that I am having a little trouble with. Thanks in advance.

    1. The problem statement, all variables and given/known data
    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
    Print "Hello"
    For j=1 to i
    Print "Hello"

    3. 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.

    1. The problem statement, all variables and given/known data

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

    2. Relevant equations


    3. 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.
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted