1. Draw the decision tree for Merge sort operating on three element; so Merge sort (A,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Draw the decision tree for Merge sort operating on three element; so Merge sort (A, 1, 3) where the input is A[1...3] = (a1, a2, a3). Use the decision tree for Insertion sort in Fig. 8.1 as a model. Note that each internal node must correspond to a comparison of two given elements from A[1...3]. What is a stable sort? 2. 3. 4. 5. 6. 7. 8. 9. Using Figure 8.4 as a model, illustrate the operation of Bucket-Sort on the array A = (.79, .13, .16, .64, .39, .20, .89., 53., .71, .42). 10. Explain why the decision tree for any comparison based sorting algorithm must have at least n! leaves. Show log n! = (n logn). Illustrate the operation of Counting-Sort on A = (6,0,2,0, 1, 3, 4, 6, 1, 3, 2). Describe an algorithm that, given n integers in the range from 0 to k, prepro- cesses the input and then answers any query on how many of the n integers fall into range [a...b] in O(1) time. Your algorithm should use O(n + k) preprocessing time. Show how to sort n integers in the range 0 to n-1 in O(n) time. Which of the following sorting algorithms are stable: insertion sort, merge sort, and quicksort (according to their implementations in the textbook)? 11. Explain why the worst-case running time for bucket sort is (n)? What simple change to the algorithm preserves its linear average-case running time and makes its worst-case running time O(n log n)? Describe a worst-case linear time algorithm that decides if a given sequence of integers (a1, a2, ..., an) is a permutation of (1, 2, 3,..., n). Your algorithm only needs to say Yes or No. (Hint: counting sort.) 1. Draw the decision tree for Merge sort operating on three element; so Merge sort (A, 1, 3) where the input is A[1...3] = (a1, a2, a3). Use the decision tree for Insertion sort in Fig. 8.1 as a model. Note that each internal node must correspond to a comparison of two given elements from A[1...3]. What is a stable sort? 2. 3. 4. 5. 6. 7. 8. 9. Using Figure 8.4 as a model, illustrate the operation of Bucket-Sort on the array A = (.79, .13, .16, .64, .39, .20, .89., 53., .71, .42). 10. Explain why the decision tree for any comparison based sorting algorithm must have at least n! leaves. Show log n! = (n logn). Illustrate the operation of Counting-Sort on A = (6,0,2,0, 1, 3, 4, 6, 1, 3, 2). Describe an algorithm that, given n integers in the range from 0 to k, prepro- cesses the input and then answers any query on how many of the n integers fall into range [a...b] in O(1) time. Your algorithm should use O(n + k) preprocessing time. Show how to sort n integers in the range 0 to n-1 in O(n) time. Which of the following sorting algorithms are stable: insertion sort, merge sort, and quicksort (according to their implementations in the textbook)? 11. Explain why the worst-case running time for bucket sort is (n)? What simple change to the algorithm preserves its linear average-case running time and makes its worst-case running time O(n log n)? Describe a worst-case linear time algorithm that decides if a given sequence of integers (a1, a2, ..., an) is a permutation of (1, 2, 3,..., n). Your algorithm only needs to say Yes or No. (Hint: counting sort.)
Expert Answer:
Answer rating: 100% (QA)
Im sorry but it seems there might be some typos or missing information in this question Please clari... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these algorithms questions
-
Business collects $5,000 from customers on account. Hint: See course materials. "Collect on account" is common terminology that you will see again. Services were performed on credit (on account) in a...
-
A road building company is purchasing an excavator for $500,000. The corporate tax rate is 45% and the expected after-tax rate of return is 12%. What would be the present value of the future tax...
-
A survey of information systems managers was used to predict the yearly salary of beginning programmer/analysts in a metropolitan area. Managers specified their standard salary for a beginning...
-
Use a histogram to graph the cumulative frequencies. Use the following information to answer question. Suppose a class of high school seniors had the following distribution of SAT scores in English....
-
Solve Prob. 10.30 assuming that the 900-N load is applied at C instead of E. Problem 10.30: Two bars AD and DG are connected by a pin at D and by a spring AG. Knowing that the spring is 300 mm long...
-
Polska SA, in preparation of its December 31, 2022, financial statements, is attempting to determine the proper accounting treatment for each of the following situations. 1. As a result of uninsured...
-
How does component-based development help reuse?
-
Freds Auto Components manufactures seats for an automobile company. The automobile company wants a new seat designed to accommodate drivers and passengers who weigh 200 pounds or more and at a price...
-
2. Another dielectrics-filled spherical capacitor Given a spherical capacitor with dielectrics in between for two different cases below, find the net capacitance of the spherical capacitor for both...
-
From the data 1,4, 5, 3, 2, 5, 7, 3, 4, and 5, Poindexter created the following frequency table. What five things did he do wrong? f- 013589 f- 11223|-| 123457
-
In a random sample of 200 claims filed against an insurance company writing collision insurance on cars 84 exceeds 1200 construct a 95% of confidence interval for the true proportion of claims field...
-
Considering environmental impacts, what is more beneficial in a green building project?
-
She is single with no dependents. She worked for the same camp last year and received a full refund of all the federal taxes they withheld because she had no tax liability. She expects this year to...
-
Return on Investment (ROI): 15% Payback Period: 3 years Net Present Value (NPV): R50,000 Internal Rate of Return (IRR): 12% Cash Flows: Year 1: R20 000 Year 2: R30 000 Year 3: R40 000 1.4 Calculate...
-
Use marketing strategies to raise sales Cut labor costs to lower expenses Raise prices to raise profits Cut food costs to lower expenses. What should a manager do when revenue consistently falls...
-
What is normally subtracted from cost of goods sold (COGS) when calculating inventory days, and why?
-
You are a computer programmer working for a small business that provides specialized financial services to local, mostly small businesses. You have been working for company X for about six months....
-
Assume today is the 21st of February. Using the information below, FT Extract, answer the following questions (parts i and ii). You work for a US company that is due to receive 250 million in June...
-
Let T be a minimum spanning tree of a graph G = (V, E), and let Vbe a subset of V. Let Tbe the subgraph of T induced by V, and let G be the subgraph of G induced by V. Show that if T is connected,...
-
Write pseudocode for MAKE-SET, FIND-SET, and UNION using the linked-list representation and the weighted-union heuristic. Make sure to specify the attributes that you assume for set objects and list...
-
Show the red-black trees that result after successively inserting the keys 41, 38, 31, 12, 19, 8 into an initially empty red-black tree.
-
A probability experiment consists of rolling a single fair die. (a) Identify the outcomes of the probability experiment. (b) Determine the sample space. (c) Define the event E = roll an even number....
-
Sophia has three tickets to a concert, but Yolanda, Michael, Kevin, and Marissa all want to go to the concert with her. To be fair, Sophia randomly selects the two people who can go with her. (a)...
-
A pair of fair dice is rolled. Fair die are die where each outcome is equally likely. (a) Compute the probability of rolling a seven. (b) Compute the probability of rolling snake eyes; that is,...
Study smarter with the SolutionInn App