Question

In: Computer Science

(a) Given a 4×4 grid, how many different paths from (0,0) to (4,4) satisfy the following...

(a) Given a 4×4 grid, how many different paths from (0,0) to (4,4) satisfy the following condition:

• You can only go from (x, y) to either (x+1, y) or (x, y+1)

(b) Given a 4×4 grid, how many different paths from (0,0) to (4,4) satisfy the following condition:

• You can only go from (x, y) to either (x+1, y) or (x, y+1)

• You cannot go to points (x, y) where y > x, in other word, you cannot cross line y = x

(c) How many sequences of 4 pairs of parentheses are mismatched? An example of a matched sequence of paretheses is ()()()(), while a mismatched sequence is )))(((.

Solutions

Expert Solution

(a) To go from (0,0) to (4,4), you will have to take 4 steps right in x axis (say,r), and 4 steps up in y axis (say, u). Thus, we need to find the total number of combinations of 4r and 4u, eg. rrrruuuu. So, for the total 8 places we can select any four place and keep r, while we can keep u in the remaining places. This can be found using the formula for combination: C(n,k)=((k!)/(k! * (n-k)!)). Keeping n=8, k=4, we have C(8,4)=70.

(b) The given question can be understood as: we need to arrange four r and four u in such a way that number of r is always greater than the number of u going from left to right. We can do this using the Catalan number as C(2k,k)/(k+1), ie, C(8,4)/(4+1)=70/5=14.

(c) Number of mismatched paranthesis = Total number of possible combinations of four ( and four ) - Number of matched arrangements. Suppose, we mark the opening parentheses ( as r and the closed parentheses ) as u. Then we can get the total possible combinations using question (a) and number of matched combinations using (b). Thus, number of mismatched paranthesis=70-14=56.


Related Solutions

Evaluate the line integral along the given paths. xy ds (a) C: line segment from (0,0)...
Evaluate the line integral along the given paths. xy ds (a) C: line segment from (0,0) to (5, 4) C: counterclockwise around the triangle with vertices (0, 0), (8, 0), and (0, 2)
Consider a grid with vertices from (0,0) to (20,20), in which edges can only be traversed...
Consider a grid with vertices from (0,0) to (20,20), in which edges can only be traversed up or right. Think of a street grid with intersections labelled by pairs of integers, and all one-way streets. How many paths, going only up and right, are there in the grid which do not pass through either forbidden intersection, if: (1) There are forbidden nodes at grid points (12,7) and (7,12)? (2) There are forbidden nodes at grid points (6,6) and (13,13)?
For a 4 mile by 4 mile grid, how many signs must be placed to ensure...
For a 4 mile by 4 mile grid, how many signs must be placed to ensure that the farthest distance between two signs is LaTeX: \sqrt[]{2} 2 miles?
From the following information, decide how many segments would be reported to satisfy the appropriate tests...
From the following information, decide how many segments would be reported to satisfy the appropriate tests of segmented reporting: SEG UNAFFIATED REV TOTAL REV OPERATING PROFIT/LOSS SEGMENT ASSETS A $90 $280 $120 $70 B $80 $100 $10 $350 C $10 $60 $ (5) $90 D $330 $350 $0 $240 E $300 $400 $ (100) $230 F $300 $380 $160 $560 TOTAL $1,110 $1,570 $185 $1,540 REVENUE TEST- OPERATING PROFIT/LOSS- SEGMENT ASSETS- REPORTABLE SEGMENTS- Does the above selected assets meet eh...
How many different 4 card hands can be dealt from a deck of 52 cards? The...
How many different 4 card hands can be dealt from a deck of 52 cards? The order of the cards does not matter in this case.
(a) How many different committees consisting of 3 males and 4 females can be chosen from...
(a) How many different committees consisting of 3 males and 4 females can be chosen from a group of 8 males and 7 females? (b) In how many ways can 5 essays be ranked in a contest? (c) A license plate has three letters from 26 letters of an alphabet and four digits from 0,1,2,3,4,5,6,7,8,9. How many plates can be made if: i) letters and numbers cannot be repeated? ii) repetitions are allowed?
1. From 7 consonants and 5 vowels,how many words can be formed consisting of 4 different...
1. From 7 consonants and 5 vowels,how many words can be formed consisting of 4 different consonants and 3 different vowels? The words need not have meaning. 2. In the game of poker5 cards are drawn from a pack of 52 well-shuffled cards. Find the probability that (a) 4 are aces, (b) 4 are aces and 1 is a king, (c) 3 are tens and 2 are jacks, (d) a nine, ten, jack, queen, king are obtained in any order,...
What are the different paths from a purchase requisition to a purchase order? What determines which...
What are the different paths from a purchase requisition to a purchase order? What determines which path is selected?
1. (a) How many integers from 197 to 603 are divisible by 4? (b) How many...
1. (a) How many integers from 197 to 603 are divisible by 4? (b) How many integers from 97 to 995 are divisible by 6? (c) If the largest of 87 consecutive integers is 255 then what is the smallest? 2. Compute the following: (a)9! (b)P(15,8) (c)8! (d)P(3,6)
How many different gametes could you get from an individual with the genotype WWDd? How many...
How many different gametes could you get from an individual with the genotype WWDd? How many different offspring (phenotypes) will you get from following cross: TtGg x TtGGC Defined as different forms of a gene. Mitosis is defined as If tall is dominant over short and green flowers are dominant over white flowers, what would the phenotype(s) be for the following cross ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT