String of N characters containing M(<N) words

  • Context: High School 
  • Thread starter Thread starter Vance
  • Start date Start date
  • Tags Tags
    String
Click For Summary

Discussion Overview

The discussion revolves around the problem of determining the number of ways to parenthesize a string of N characters containing M words, where M is less than N. Participants explore various conditions related to the rules of punctuation, nesting of parentheses, and the implications of these rules on the counting of parenthetical arrangements.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Some participants question whether ordinary punctuation rules apply and whether parentheses can break up words or be nested.
  • One participant suggests that if words cannot be split, the number of characters (N) may not be relevant, only the number of words (M) matters.
  • Another participant proposes a formula involving summation to calculate the number of ways to parenthesize based on the arrangement of words.
  • There is a discussion about the validity of multiple parentheses and various configurations, with examples provided to illustrate possible arrangements.
  • One participant introduces a mathematical operator conceptually similar to factorial but for addition, seeking a more efficient notation for sums.
  • A formula is presented by a participant that calculates the number of ways to parenthesize under specific conditions, with a note on not counting the case of no parentheses.
  • Another participant expresses interest in the recursive nature of the formula and seeks clarification on the method used to derive it.
  • Further elaboration on the recursive approach is provided, detailing how combinations change with the addition of new words.
  • One participant shares a recursive relationship for the function F(m) that describes the number of ways to parenthesize based on previous values.

Areas of Agreement / Disagreement

Participants express differing views on the rules governing parentheses, particularly regarding nesting and splitting words. There is no consensus on a definitive formula or method, as various approaches and interpretations are presented.

Contextual Notes

Limitations include the dependence on the definitions of allowed parenthetical structures and the unresolved nature of the mathematical expressions and formulas discussed.

Vance
Messages
180
Reaction score
0
I have a string of N characters containing M(<N) words. Can you tell me how many way I can parenthize this string ? :shy:

So so :cool: COOL not kewl
 
Mathematics news on Phys.org
Sum(n-i,i,1,n-1)
 
Last edited:
Vance said:
I have a string of N characters containing M(<N) words. Can you tell me how many way I can parenthize this string ? :shy:

So so :cool: COOL not kewl

Do we use ordinary rules of pu(nctua)tion?

Parenth(eses are not allo)wed to break( up (words), or be) nested?

If one cannot break up words, then I think the number N of characters does not matter, only the number M of words matters.

It does seem to matter whether or not you want to allow nesting parens.
 
Healey01 said:
Sum(n-i,i,1,n-1)

hi Healey, I don't know this notation, can you give an example
or explain it simply?
If there were just 4 words, how would your formula work to give
the number of different ways to parenthesize?
 
I assumed that you cannot parenthesize throughout words, like splitting them up. He states that there are M words, with M < N. So the maximum amount of words would be N-2 single characters, then a double character word. like a 4 letter max would be :
a b cd

in order to have M<N.

Then possible parentheticals are
(a) b cd
(a b) cd
(a b cd)
a (b) cd
a (b cd)
a b (cd)

cause you can't split "cd"

Then you see its just what i wrote as a sum
for the starting parenthesis in front of a you have m possibilities, which is n-1 possibilities.
For the parenthesis in front of "b' you have 2, or m-1 possibilities, or n-2 possibilities.

I guesss SUM(m-i,i,0,m-1) would work too.
 
is this allowed ?
(a) (b) (cd)
and this
a (b) (cd)

Also we may have
a bcd
can't we?

[edit]
on healey's notation
sum(m-i,i,0,m-1)
means
sum over m-i
where i goes from 0 to m-1
[/edit]
 
ahh, i forgot about multiple parenthesis. there's a lot then. I am working on the formula right now.

PS:
Is there a mathematical operator "$"(ill call it arbitrarily) such that

6$ = 6+5+4+3+2+1+0 ?
sort of like 6! = 6*5*4... but with addition? I hate writing out the sums everytime.

PPS : Oh, and I am assuming he's looking for the maximum allowed given that you can't split words. So just ignore the character number. UNLESS (crazy hard) everytime you add a parenthesis it counts as a character, so you can have that many less characters in your string...

Oh and is this allowable?

(The (swift) red) (fox).
 
Last edited:
[tex]n + (n-1) + ... + 2 + 1 = \sum_{i=1}^n i = \frac{n^2 + n}{2}[/tex]
 
Vance said:
I have a string of N characters containing M(<N) words. Can you tell me how many way I can parenthize this string ? :shy:

So so :cool: COOL not kewl

If parenthesis can't break up words, and if parenthesis can't be nested , then the answer is:

[tex]\#ways(M) = \left(\frac{5+\sqrt{5}}{10}\right) \left(\frac{3+\sqrt{5}} {2}\right)^M + \left(\frac{5-\sqrt{5}}{10}\right) \left(\frac{3-\sqrt{5}} {2}\right)^M -1[/tex]

I'm not counting the 'no parenthesis at all' case. So, if M=1 then #ways=1, for instance .
But, of course you may remove the '- 1' at the end. :smile:
 
Last edited:
  • #10
Rogerio,
Brilliantè!

Your formula seems to be agreeing with my calculations for a first few terms ... may/can i have a hint for the method u have taken?

-- AI
P.S : By the look of the formula, u seem to have got some recursive equation is it?
 
  • #11
Wow, thanks TenaliRaman !

You are right, it was a 'recurrence' approach...:-)

A little bit more in white:

Consider all the combinations with the initial words: a b...f
When you add a new word, you get:

combinations with the new last word free (not enclosed in parentheses) :
thee old '...f' becomes '...f x'

combinations with the new the last word enclosed in parentheses and alone:
the old '...f' becomes '...f (x)'

combinations with the new last word enclosed in parentheses but not alone:
the old '...f)' becomes '...f x)'

Hmmm... is it enough ? :smile:
 
Last edited:
  • #12
But Ofcourse!


F(m) = 2*F(m-1)+ [\sum_{i=1}^{m-2} F(i)] .. *
F(m-1) = 2*F(m-2) + [\sum_{i=1}^{m-3} F(i)] .. **
Simplifying with * and **, we get
F(m) = 3*F(m-1) - F(m-2)
and the rest is ofcourse mechanical.


Good Job!
-- AI
 
Last edited:

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 70 ·
3
Replies
70
Views
8K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 26 ·
Replies
26
Views
5K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K