further counting example:


> General Question:  If you take the coin-flipping question for example, and
> look at the fact that we got 2^4 possible outcomes.how does that relate to
> combinations and permutations?  Or does it?  Can you the answer we got.2^4
> in terms of a combination or permutation?
> 
They don't relate very much -- the product rule (used 4-1 times) is about
independent choices, and combo's and perm's are about non-independent
choices (that is, which choice you make for the first few options may
restrict your choices for later options).

Well okay, there is *some* relation in that:
2^4   =   # of outcomes in tossing four coins
      =   # of outcomes w/ exactly 0 heads
        + # of outcomes w/ exactly 1 head
        + # of outcomes w/ exactly 2 heads
        + # of outcomes w/ exactly 3 heads
        + # of outcomes w/ exactly 4 heads
      = C(4,0) + C(4,1) + C(4,2) + C(4,3) + C (4,4)

In general, Sum (i from 0 to n) C(n,i) = 2^n.
(In lecture I gave this, tied in with the binomial coefficients for (1+1)^n.)

But this is a tangential relation between 2^4 and comb/perms.
For comparison & contrast, consider two approaches to counting:
In a class of 30 students, y'all get together and realize that you don't
*all* have to take notes; you appoint one note-taker for the week, and
photocopy the notes for everybody else.

Q: How many ways are there to appoint a weekly note-taker, for 14 weeks?
That is, how many ways to fill names in the blanks:

_______  _______  _______ ... _______  _______  
 week1    week2    week3       week13   week14   

A1: If somebody can be a note-taker more than once:
  E.g.  Amy,Brad,Cary,Dan,... is one possibility, and
        Amy,Brad,Brad,Cary,Amy,... is another, and ...
then there are 30 choices for week1, 30 choices for week2, (etc),
for a total of 30^14 ways.
(This is the product rule, since the choice for one week doesn't
effect the choices for later weeks).
  In this approach, are we saying order matters?
  Yes -- a schedule starting "Amy Brad ..." is different
  than any schedule starting "Brad Amy ...".

A2: If you don't have to be note-taker for more than one week
(no repetitions allowed), then we have 30 ways for week1, 29 ways for week2,
..., and 17 choices for week14,
for a total of 30*29*...*17 = 30!/16! = P(30,14) ways.
   In this approach, are we saying order matters?
   Yes, same reasoning as before.

A3: What if we *don't* care about the order, we just want to know
    how many different schedules there are, where nobody repeats?
    (That is, filling in the blanks Amy,Brad,Cary,Dan,...,Neville
     is considered the same schedule as filling in the blanks
     Brad,Amy,Cary,Dan,...,Neville, or in fact *any* of the 14! ways
     of arranging Amy..Neville.)
    Here the answer is C(30,14) = 30!/(16!14!).
    (Why?  Take the list generated for A2 and look at any entry in there;
     that entry was listed 14! times, but we only want to count it once.)

Just looking for yet more variations on a theme...

A4: What if we still don't care about the order, and we *do*
    allow repetitions?  That is, after filling in the blanks above,
    we consider all the combinations that have Amy twice, Brad once,
    and Cary the remaining 11 times to be the same (regardless of
    which order they did those weeks).

    In this case, we think about the problem differently, and see
    that there are 30 "brands" of students, and we want to purchase
    14 items from any of the brands.
    This is the clever trick from lecture/reading where we think:
      ``I have 14 blanks to fill in, and 30-1 Dividing Lines to draw
        in between those 14 blanks, delimiting the brands
         [So amy will cover as many lectures as up to the first placed
          stick, Brad will cover as many slots as between the first and
          second stick, etc.]''
       The clever bit is to say "rather than distribute 29 sticks
       *between* the blanks, we'll add 29 additional blanks,
       and out of the total of 29+14 blanks we want to choose 29 of them
       as ending up w/ sticks: C(29+14,29) = 43!/29!14!


A5: What if somebody can be note-taker more than once, but there's some
    sort of term-limit (say, nobody can be note-taker more than thrice?)
    This is a *very* different problem than any of the above;
    none of the standard ways we covered in class will do it.
    ...Off the top of my head, I can't think of any way to count this exactly.
    (One thought is to say I have not 30 students, but 90: Amy1,Amy2,Amy3,
    Brad1, ... .  Arrange these to take notes, and then try to
    divide out the (up to 3!) repetitions of Amy, and the (up to 3!) repetitions
   of Brad, etc.
    The problem is, different schedules have different number of repetitions
    of Amy, etc.
    So that wouldn't work.


> [problem 2]  --- I can generate a constant factor, but I'm not quite sure as
> to how I can retrieve a big-oh function from this.  To sum up what I did, I
> looked at the ratio of strings of length n over the big summation.  With the
> summation rules, I was able to get it to 25*(26^n) /  (26^(n+1) - 1).  I'm
> assuming if you ignore the "-1" part, then the constant factor would be
> 25/26.  But how do you factor the error into this result?
> 
>  
Re-write your fraction as exactly 25/26 + [something].
Then, express the [something] part in big-Oh notation.

But how to re-write our fraction like that?
Well, 
  25/26 + [something] = [your expression above].
Then solve for [something], which will be a function of n.
Then, to get [something] as being a nice big-Oh (instead of a big-Oh
with an ugly "...-1" in it's denominator), you can use inequalities and
the play allowed by big-Oh to make it look nice.



> [problem 3]  --- part C, you say you have a common word that has two
> letters' capitalization changed, and one other letter replaced by a digit.
> Let's say you have two words fable and table.  And then you replace fable &
> table with the number 5 in the exact same location.  Then you have 5able and
> 5able.  Does that mean you'll have a lot of repetitions when counting?  How
> would you "weed" it out of your result?
> 
*Excellent* point.
So excellent in fact, I hadn't intended that glitch to be there.
(The exact number suddenly is dependent on the particular dictionary of words --
how many common words happen to be within one letter-substitution of each
other?  Btw, this is related to: if somebody is emailing you a word,
and a single letter gets garbled, can you uniquely reconstruct the message?
People in networking worry about this.)

Change this problem: EITHER
(a) instead of replacing a digit by a letter, *insert* a digit.
or
(b) assume that all common words differ by at least two letters
    (so if "table" is common, then:
     "fable" can't be, but "title" is still okay.)
State which of these two assumptions you're making.


> [problem 7] --- part f, I'm having problems dealing with the broccoli case,
> where you want no more than 3 croissants in your selection.  As of now, I'm
> taking the total, which I got from an equation in the chapter, and then I'm
> subtracting out all the things I wouldn't want.  Like for example, if you
> need at least 2 apple pies, then I'd subtract C(24, 1) and C(24,0) like how
> we discussed Friday.  Is that right?  Because when I add the broccoli factor
> in.(trying to subtract c(24, 4) and so on), then the numbers get all screwy.
> 
Have to be a bit careful: if you take
  total-orders minus orders-with-0-apple minus orders-with-1-apple
               minus orders-with-4-broccoli minus orders-with-5-broccoli
               minus ... minus orders-with-24-broccoli,
then the counting is a bit off: subtracting "orders-with-4-broccoli"
was subtracting orders that happened to have 0 apples, which you *already*
subtracted.
(You're not subtracting disjoint sets.)
We could consider inclusion/exclusion, but after a bit of thought,
we realize that's going to be utter hell.

And of course, it's awfully tedious to do 21 different broccoli subtractions.

Thought #1: for the broccoli, it's probably easier to look at the
three positive cases: exactly-0, plus exactly-1, plus exactly-2.
*Within* each of these cases, you can consider the apple-restrictions.

Thought #2: Hmm, is there a way to simplify the "24 croissants, at least
two of which are apple"?  That's filling in 24 slots, where order doesn't
matter.  But hey, really, two of your choices are already made for you.
Can we leverage that?

I'm not good at big cases, so I'll make a small test case,
focussing on just the apple croissants:
- How many ways are there to buy 3 croissants, such that 2 are apple?
- Okay, what about 4 croissants, such that two are apple?
  How to count these methodically?
- Now 5, ...
- Of course, as a CompSci major, I always want to come up w/ degenerate,
  smart-ass test cases: If I need to buy 2 croissants such that 2 are apple,
  then how many ways can I do that?