Question
There are some discrete math question I wondering: A. Find a compound proposition involving the propositional variable p, q, r that is true when exactly
There are some discrete math question I wondering:
A. Find a compound proposition involving the propositional variable p, q, r that is true when exactly two of p, q, and r are true, and is false otherwise.
B. Consider the following algorithm FindMaxMin that returns both the maximum number M and the minimum number m of a group G of n numbers. For simplicity, we assume that n is a power of 2 (so n could only be equal to 2, or 4, or 8, or 16, or so on.) FindMaxMin(G) 1. If G contains only two numbers, then compare these two numbers, set M to be the larger one, and set m to be the smaller one; 2. Else, (a) Divide G into two halves G1 and G2; (b) Apply FindMaxMin on G1 to get the maximum number M1 and the minimum number m1 of G1; (c) Apply FindMaxMin on G2 to get the maximum number M2 and the minimum number m2 of G2; (d) Compare M1 and M2, and set M to be the larger of them; (e) Compare m1 and m2, and set m to be the smaller of them; 3. Return M and m as the desired maximum and minimum numbers of G;
For example, suppose G contains four numbers, 5, 8, 4, and 2. Apply FindMaxMin on G will first divide G into two halves G1 and G2, say G1 contains 5 and 8, and G2 contains 4 and 2. Next, we will apply FindMaxMin on G1, and FindMaxMin on G2. This gives us M1 = 8, m1 = 5, M2 = 4, and m2 = 2. Finally, we compare M1 and M2, and set M = 8. Also, we compare m1 and m2, and set m = 2. In this case, the numbers M and m turn out to be the desired maximum and minimum numbers of G. Moreover, the total number of comparisons is 4. (a) Show that FindMaxMin is correct. That is, for any G with a 2-power of numbers, FindMaxMin always returns correctly the maximum and minimum numbers of G. (b) Let T(2^k) denote the number of comparisons that FindMaxMin uses when G contains 2^k numbers. Briefly explain why the following two formulas are correct: T(2) = 1; T(2^k) = 2 T(2^(k1)) + 2 for any integer k 2. (c) Show that T(2^k) = 3 2^(k1) 2 for any integer k 1.
Thank you very much! I'm very appreciate to your help! Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started