2. Consider the following type of Bucket Sort. You have an array of n words, each...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Consider the following type of Bucket Sort. You have an array of n words, each composed of the usual 26 English letters A,B,..., Z Suppose you placed the words in 8 buckets based on the first letter, with buckets for ABC, DEF, GHI, JKL, MN, OPQR, ST, and UVWZYZ. The plan is to sort the 8 buckets and then stack the sorted buckets back into the original array. Don't worry about storage for the buckets. 2.1. (2). The best possible case is for each of the 8 buckets to contain exactly n/8 words. Suppose we sort each of these 8 buckets with selection sort. (not a good sorting method, but it does have an exact work function). Give an exact expression for the total work w(n) required in this best case to sort all 8 buckets. 2.2. (2). The worst case would be if one bucket had all n words and the other 7 buckets had zero works. Give an exact expression for the total work w(n) in this situation. 2.3. (2) To get an idea of the average work, a "probably below average" situation would be if 4 buckets each had n/4 words and the other 4 had zero words. Give an exact expression for the total work w(n) in this situation. Make an effort to write the answer in as simple a form as possible. 2.4. (2) How much work (number if IF statements) is needed to sort the 12 words into the 8 buckets? Hint: is there an optimal way to do this? 2.5. (2) Combining the work discussed in 2.4 and the best case discussed in 2.1, what is the total work needed in the best case? 2.6. (2) Now consider the above problems, except with k buckets rather than 8. Assume that kn. Give a formula in terms of n and k for the best case total work. (formula should reduce to that of 2.5 ifk = 8). 2.7. (2) Consider problem 2.6 except this time use quicksort rather than selection sort for sorting the buckets. For simplicity, assume that quicksort of a size n array always takes exactly Was(n) = anlgn work for some constant a. Give an exact formula for the work needed in terms of n. k. and a. 2. Consider the following type of Bucket Sort. You have an array of n words, each composed of the usual 26 English letters A,B,..., Z Suppose you placed the words in 8 buckets based on the first letter, with buckets for ABC, DEF, GHI, JKL, MN, OPQR, ST, and UVWZYZ. The plan is to sort the 8 buckets and then stack the sorted buckets back into the original array. Don't worry about storage for the buckets. 2.1. (2). The best possible case is for each of the 8 buckets to contain exactly n/8 words. Suppose we sort each of these 8 buckets with selection sort. (not a good sorting method, but it does have an exact work function). Give an exact expression for the total work w(n) required in this best case to sort all 8 buckets. 2.2. (2). The worst case would be if one bucket had all n words and the other 7 buckets had zero works. Give an exact expression for the total work w(n) in this situation. 2.3. (2) To get an idea of the average work, a "probably below average" situation would be if 4 buckets each had n/4 words and the other 4 had zero words. Give an exact expression for the total work w(n) in this situation. Make an effort to write the answer in as simple a form as possible. 2.4. (2) How much work (number if IF statements) is needed to sort the 12 words into the 8 buckets? Hint: is there an optimal way to do this? 2.5. (2) Combining the work discussed in 2.4 and the best case discussed in 2.1, what is the total work needed in the best case? 2.6. (2) Now consider the above problems, except with k buckets rather than 8. Assume that kn. Give a formula in terms of n and k for the best case total work. (formula should reduce to that of 2.5 ifk = 8). 2.7. (2) Consider problem 2.6 except this time use quicksort rather than selection sort for sorting the buckets. For simplicity, assume that quicksort of a size n array always takes exactly Was(n) = anlgn work for some constant a. Give an exact formula for the work needed in terms of n. k. and a.
Expert Answer:
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these computer network questions
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
The table contains real data. MySpace U.S. Advertising Revenue ($ millions) (a) Determine the maximum and minimum values for each variable in the table. (b) Use your results from part (a) to find an...
-
Margaret wants to buy a car when she graduates from Central University four years from now. She believes that she will need $30,000 to buy the car. Required a. Calculate how much money Margaret must...
-
In the WSClock algorithm of Fig. 3-20(c), the hand points to a page with R = 0. If = 400, will this page be removed? What about if = 1000?
-
A person donates a bag of clothes to Goodwill completely unaware that there is valuable sterling silver in the bag. The clothing and silver are subsequently sold, for a very economical price, to...
-
Johnson Cogs wants to set tip a line to serve 60 customers per hour. The work elements and their precedence relationships are shown in the following table. a. What is the theoretical minimum number...
-
Our company makes school buses. Here is some data on the cost of producing these vehicles. Monthly Production Data Output 0 1 2 3 4 5 6 7 8 9 10 Total cost 200,000 400,000 575,000 725,000 850,000...
-
L. The switch has been open for a long time before it is closed at t=0. C0.2 F, C = 0.8 F, R = 500 m2, R = 100 0, L= 20 mH, L= 80 mH, M = 10 mH. a) b) c) 100V (= M R CRC Lo 312 Derive the equivalent...
-
Read scenarios one to four and determine the research design and strategy that you will use to address the research questions/ objectives. Please provide justifications for your decisions. 1. The...
-
What is the fundamental difference between attitudes and values and when communicating to effect change, which has a more powerful and long-term influence, attitude change or value change?
-
Sally needs to record a sales tax deposit of $375.23. What steps should she take to record this deposit? How they can be recorded in QBO.
-
How many hours would it take for 500 mL of intravenous (IV) solution to be delivered if it is flowing at 60 drops/ minute? This set is calibrated at 100 drops per mL.
-
answer the following questions. You can refer to external resources while answering questions. Q1. James is a scientist for a local manufacturer that employs a large percentage of the small town...
-
Sarah Limited leased a machine which had a fair value of $57,030 to Jane Limited on 30 June 2018 with the following terms: Lease term 4 years Annual Rental Payment in arrears starting from 30 June...
-
Why do bars offer free peanuts?
-
Determine the running time of Shellsort for a. Sorted input b. Reverse-ordered input
-
Write a program that reads N points in a plane and outputs any group of four or more colinear points (i.e., points on the same line). The obvious brute-force algorithm requires O(N4) time. However,...
-
In a recent court case, a judge cited a city for contempt and ordered a fine of $2 for the first day. Each subsequent day, until the city followed the judge's order, the fine was squared (that is,...
-
The following demonstration problem illustrates the use of the general journal, the four special journals introduced here, and the general ledger with two subsidiary ledgers. Sidney Carton began...
-
Tymonns Traders Ltd uses sales and purchases journals in its accounting system. The following transactions occurred during April 2019. Required (a) Complete the requirements below, assuming the...
-
On 30 June 2019 the following information appeared in the accounting records of Ndung and Mkoka. Balance of Accounts Receivable Control account, $3725 Total of schedule of accounts receivable,...
Study smarter with the SolutionInn App