Question

Disclaimer: This is just One question with multiple parts. It is not multiple questions in one...

Disclaimer: This is just One question with multiple parts. It is not multiple questions in one post.

Question:

Consider the problem of finding both the maximum and the minimum. We
will show that you can not find them both in less than (about) 3n/2 comparisons.


Consider the run of any algorithm and defined the following sets that depend on the
comparison the algorithm chose. Let N be the collection of numbers. We denote n = |N |. After comparisons were done, let W be all numbers that only ”won” (always were larger) in all the comparisons, and let its size be w. Let L be the set of numbers who always ”lost” and lets its size be `. Let B be the set of those who both lost least once and won at least once.


1. Show that there is always an input so that if a member u ∈ W is compared to a
number not in W , u wins.


2. Show that there is an input so that if a member u ∈ L is compared to a number
not in L, u looses.


3. Show that when the algorithm stops, there is exactly one element in W , exactly
one element in in L and the rest of the elements belong to B.


4. Recall that n = |N |, w = |W |, ` = |L|, and consider 3n + 2w + 2`. Show that at
start the value is 3n and at the end at the end its 4


5. Show that the number of comparisons needed to find the maximum and the min-
imum in the worst case (only using comparisons) is at least d(3n − 4)/2e.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Show that there is always an input so that if a member u ∈ W is compared to a number not in W , u wins.

Now if we consider that u loses to a number (say num) not in W then num can't be part of L as L has member which always lost. Also there always exist one number in B which would have lost to a number in W.

So this contradict our assumption and hence there always exist such a number in w

2. Show that there is an input so that if a member u ∈ L is compared to a number not in L, u looses.

Now lets consider that u wins when compared with number not in L.

u can't win with number in W as number of w always won. Also there always exist a number in L which would have lost to all number in B.

Hence this contradict our assumption and hence such a number exist.

3.

Show that when the algorithm stops, there is exactly one element in W , exactly one element in in L and the rest of the elements belong to B.

When algorithm stop, let there are two number in W. This means that these two numbers which were never compared otherwise one of them will not remain in w. So this can't happen and hence there will be only one number in W.

Similar argument holds for L.

Question 4 and 5 are not clear

4. Recall that n = |N |, w = |W |, ` = |L|, and consider 3n + 2w + 2`. Show that at
start the value is 3n and at the end at the end its 4


5. Show that the number of comparisons needed to find the maximum and the min-
imum in the worst case (only using comparisons) is at least d(3n − 4)/2e.

Add a comment
Know the answer?
Add Answer to:
Disclaimer: This is just One question with multiple parts. It is not multiple questions in one...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Let be a permutation of {1,2,……n}.Let -1 be the (n-1)-tuple with one element from missing. Alice...

    Let be a permutation of {1,2,……n}.Let -1 be the (n-1)-tuple with one element from missing. Alice shows Bob -1[i] one by one in the increasing order of i from 1 to (n-1).bob’s task is to compute the missing element from -1 that is in with very limited – O(log n) bits – of memory. Design an algorithm to compute the missing element in this memory-limited and access-limited model, i.e Alice can only show each number to Bob once, and Bob...

  • just trying to get the solutions to study, please answer if you are certain not expecting...

    just trying to get the solutions to study, please answer if you are certain not expecting every question to be answered P1 Let PC 10, +00) be a set with the following property: For any k e Zso, there exists I E P such that kn s 1. Prove that inf P = 0. P2 Two real sequences {0,) and {0} are called adjacent if {a} is increasing. b) is decreasing, and limba - b) = 0. (a) Prove that,...

  • Example 1.9: 1.23 "The median of an ordered set is an element such that the number...

    Example 1.9: 1.23 "The median of an ordered set is an element such that the number of elements less than the median is within one of the number that are greater, assuming no ties. a. Write an algorithm to find the median of three distinct integers a, b, and c. b. Describe D. the set of inputs for your algorithm. in light of the discussion in Sec- tion 1.4.3 following Example 1.9. c. How many comparisons does your algorithm do...

  • Question 1. Let Σ = {a, b}, and consider the language L = {w ∈ Σ...

    Question 1. Let Σ = {a, b}, and consider the language L = {w ∈ Σ ∗ : w contains at least one b and an even number of a’s}. Draw a graph representing a DFA (not NFA) that accepts this language. Question 2. Let L be the language given below. L = {a n b 2n : n ≥ 0} = {λ, abb, aabbbb, aaabbbbbb, . . .} Find production rules for a grammar that generates L.

  • 1 question) Arrange the following in the order of their growth rates, from least to greatest:...

    1 question) Arrange the following in the order of their growth rates, from least to greatest: (5 pts) n3                     n2         nn        lg n     n!       n lg n              2n                     n 2 question)Show that 3n3 + n2 is big-Oh of n3. You can use either the definition of big-Oh (formal) or the limit approach. Show your work! (5 pts.) 3 question)Show that 6n2 + 20n is big-Oh of n3, but not big-Omega of n3. You can use either the definition of big-Omega...

  • Question 1. Let S = {a,b}, and consider the language L = {w E E* :...

    Question 1. Let S = {a,b}, and consider the language L = {w E E* : w contains at least one b and an even number of a's}. Draw a graph representing a DFA (not NFA) that accepts this language. Question 2. Let L be the language given below. L = {a”62m : n > 0} = {1, abb, aabbbb, aaabbbbbb, ...} Find production rules for a grammar that generates L.

  • 4.11.3 P4.11.3 Prove the claim at the end of the section about the Euclidean Algorithm and...

    4.11.3 P4.11.3 Prove the claim at the end of the section about the Euclidean Algorithm and Fibonaci numbers. Specifically, prove that if positive naturals a and b are each at most F(n), then the Euclidean Algorithm performs at most n -2 divisions. (You may assume that n >2) P4.11.4 Suppose we want to lay out a full undirected binary tree on an integrated circuit chip, wi 4.11.3 The Speed of the Euclidean Algorithm Here is a final problem from number...

  • Question 1: Given an undirected connected graph so that every edge belongs to at least one...

    Question 1: Given an undirected connected graph so that every edge belongs to at least one simple cycle (a cycle is simple if be vertex appears more than once). Show that we can give a direction to every edge so that the graph will be strongly connected. Question 2: Given a graph G(V, E) a set I is an independent set if for every uv el, u #v, uv & E. A Matching is a collection of edges {ei} so...

  • I don't know if this one question counts as multiple questions. If it does, please help...

    I don't know if this one question counts as multiple questions. If it does, please help me with the first part and tell me that it counts as multiple parts. 4. Consider a random walk on the integers in which the particle moves either two units to the right (with probability p) or one unit to the left (with probability q1 p) at each stage where O < p1. There is an absorbing barrier at 0 and the particle starts...

  • 10. Consider the Traveling Salesperson problem (a) Write the brute-force algorithm for this proble that considers...

    10. Consider the Traveling Salesperson problem (a) Write the brute-force algorithm for this proble that considers (b) Implement the algorithm and use it to solve instances of size 6, 7, (c) Compare the performance of this algorithm to that of Algorithm all possible tours 8, 9, 10, 15, and 20 6.3 using the instances developed in (b) Algorithm 6.3 The Best-First Search with Branch-and-Bound Pruning Algorithm for the Traveling Salesperson problem Problem: Determine an optimal tour in a weighted, directed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT