English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Solve the following counting problems. In each case show the reasoning that led you
to the answer.

(a) A palindrome is a word that reads the same forwards and backwards. How many
seven-letter palindromes can be made from the English alphabet?

(b) How many bit strings of length 10 begin with three 0s or end with two 1s?

(c) How many bit strings of length 10 contain either five consecutive 0s or five consecutive
1s?

(d) How many truth tables are there for propositions with n variables?

(e) Suppose you have n beads, each of a different color, that you need to string into a
necklace? How many distinct necklaces can you make? (A necklace flipped over
remains the same and does not count as a distinct necklace.)

2007-11-18 13:34:32 · 2 answers · asked by David 2 in Science & Mathematics Mathematics

2 answers

Question (a) is especially difficult as stated since "word" isn't defined mathematically.

If you reword the problem to say something like "How many seven-letter palindromic strings can be made from the English alphabet?", the answer is 26^4, because there are 26 possibilities for each of the first four places in the seven-letter string. (The 5th, 6th, and 7th places are always determined by the 3rd, 2nd and 1st places respectively, so they do not enter into the calculation.)

This answer allows such 7-letter strings as "jklmlkj", which is clearly not any kind of word. If one insists on only words, the calculation can be made closer to correct by saying 24^3 x 6, where 6 represents the choice of one of six vowels, since every English word must contain at least one vowel. This last estimate is not the number of palindromic words in English, but is the number of palindromic strings which must be examined to see if they form actual words.

2007-11-18 20:36:11 · answer #1 · answered by Roger the Mole 7 · 0 0

length PROC MOV CX,0 ;Initialize result MOV BX,DX ;BX -> String MOV AL,0 ;to seek for Str end ; returned: CMP AL,[BX] ;String ends? JE END_LENGTH ;if so: bounce to end ; INC CX ;Increment length INC BX ;improve pointer JMP returned ;and repeat ; END_LENGTH: RET ;bypass returned to caller length ENDP Regards... ---------------------------------------.... greater beneficial version assertion for Love4Boobies: of course, my techniques-set isn't the greater beneficial by way of try this technique; easily, is the worst in words of overall performance. I meant that Erica have not too plenty assembly adventure, so i attempted that my answer replaced into the main consumer-friendly and comprehensible one. as an occasion, i think of that MOV AL,0 is clean sufficient even to a beginner assembly programmer and that Erica in all probability don't understand why XOR AL,AL delivers an comparable result; to boot, i'm particularly advantageous that Erica do no longer cares in any understand if MOV execute some clock cycles slower than XOR as long as she gets the answer to her question and know it. Your techniques-set isn't "the main optimized way wherein this could be performed" as you reported. that is my very final version: length proc cld ;CLearDirection flag to INCrement DI in SCASB xor cx,cx ;CX = 0 dec cx ;CX = -a million mov di,dx ;DI -> String xor al,al ;AL = 0 repne scasb ;on a similar time as [DI]!=AL: INC DI and DEC CX ; ;at bypass out: CX = -a million-Lenght neg cx ;CX = a million+Lenght dec cx ;CX = Lenght ret ;bypass returned to caller length endp previous code run speedier and is ONE BYTE SHORTER (Oh, my god!) than yours... :-) i do no longer think of that those strategies be a opposition for the acceptable assembly code, yet an help for the guy that placed up the question. do no longer you think of? by potential of technique of the on a similar time as, Erica ingredient out that the technique ought to prefer to be referred to as LENGHT yet you replaced it to find_lenght. in case you supposedly furnish a much better answer than the former one, then you definately ought to prefer to additionally make clean that LENGHT is a reserved be conscious utilized by potential of technique of the assembler that could no longer available to stick to, regardless of the indisputable actuality that for the period of straightforward terms a warning (no longer an blunders) is issued if such be conscious is used as photograph. Regards... playstation - i might prefer to prefer to take heed to the opinion of Erica or different consumers approximately this count quantity quantity.

2016-11-12 01:07:39 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers