4. Design and analysis of an Algorithm (25 points) A is an array of n data...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4. Design and analysis of an Algorithm (25 points) A is an array of n data records to sort and that the key of each record has the value 0 or 1. Design an algorithm for sorting such a set of records possess the following desirable characteristics: The algorithm runs in O(n) time. The algorithm is stable. The algorithm returns A as output, i.e., A stores the final result. (1) (15 points) Pseudocode: Give an algorithm that satisfies the above criteria. The pseudocode should use the textbook conventions (2) (10 points) Analysis: Justify your algorithm runs in O(n) time and why it is stable. What is the space complexity of your algorithm? 7. To sort a set of data, the data must be compared and moved as necessary. The efficiency of these two operations depends on the size of the data set. for d = 1 to the position of the leftmost digit of the longest number distribute all numbers in data[ ] among queues through 9 according to the dth digit; put all integers in data[ ]; Figure 3: Pseudocode for sorting algorithm X. a) Based on pseudocodes in Figure 3, identify the name of the sorting algorithm. b) Identify the complexity for sorting algorithm X in Figure 3. (2 Marks) (2 Marks) [Total: 4 Marks] 4. Design and analysis of an Algorithm (25 points) A is an array of n data records to sort and that the key of each record has the value 0 or 1. Design an algorithm for sorting such a set of records possess the following desirable characteristics: The algorithm runs in O(n) time. The algorithm is stable. The algorithm returns A as output, i.e., A stores the final result. (1) (15 points) Pseudocode: Give an algorithm that satisfies the above criteria. The pseudocode should use the textbook conventions (2) (10 points) Analysis: Justify your algorithm runs in O(n) time and why it is stable. What is the space complexity of your algorithm? 7. To sort a set of data, the data must be compared and moved as necessary. The efficiency of these two operations depends on the size of the data set. for d = 1 to the position of the leftmost digit of the longest number distribute all numbers in data[ ] among queues through 9 according to the dth digit; put all integers in data[ ]; Figure 3: Pseudocode for sorting algorithm X. a) Based on pseudocodes in Figure 3, identify the name of the sorting algorithm. b) Identify the complexity for sorting algorithm X in Figure 3. (2 Marks) (2 Marks) [Total: 4 Marks]
Expert 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 computer network questions
-
Suppose that we have an array of n data records to sort and that the key of each record has the value 0 or 1. An algorithm for sorting such a set of records might possess some subset of the following...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Evaluate each expression if possible. V0.49
-
Morrow Corporation had only one job in process during May-Job X32Z-and had no finished goods inventory on May 1. Job X32Z was started in April and finished during May. Data concerning that job appear...
-
Analyze the Nike data given in Internet and Computer Exercises 1 of Chapter 15. Do the three usage groups differ in terms of awareness, attitude, preference, intention, and loyalty toward Nike when...
-
What are three best practices to keep projects on track?
-
Elegant Decor Companys management is trying to decide whether to eliminate Department 200, which has produced losses or low profits for several years. The companys 2013 departmental income statement...
-
On January 1, 2019, Shirley Corporation leased a machinery from Joel Company on a five-year lease term at P150,000 annual rental payments, paid in advance. There is a bargain purchase option on...
-
For R, partition the data sets into 60% training and 40% validation and implement the 10-fold cross-validation. Use the statement set. seed(1) to specify the random seed for data partitioning and...
-
Operating Tax Losses NOTE: Each of the tax situations listed below is independent. a) In 2020, its 1st year of operations, Reckoner Inc. has a net operating loss of ($220,000). Assume Reckoner...
-
Find the Download the latest version of the World Competitiveness Report: http://www.weforum.org/reports?filter[type]=Annual%20Reports. country ranking in terms of infrastructure quality. Find the...
-
Pick a project that you could do for a local company or government office. Examples include Establishing a social media presence. Creating a brochure, web page, or series of infographics. Revising...
-
Solve the onedimensional heat conduction problem 6 using the RayleighRitz method. For the heat conduction problem, the total potential can be defined as Use the approximate solution...
-
Solve the differential equation in problem 2 using (a) two and (b) three finite elements. Use the finite element approximation. Plot the exact solution and two and threeelement solutions on the same...
-
Solve the following simultaneous system of equations using the matrix method: 4x+2x2=2 2x1 +3x2=4.
-
For b; for certain simple linear regression we have the following information: n=31 b; =1.26, 2(X,-X)= 530.45 SSE=1550.32, and t 0,025, 31=2.042, t 0.025, 29=2.045 or t 0.05, 29=1.699 then your...
-
3.16. For a system with non-identical service rates (see Sect. 3.5) and a limit of N jobs in the system (Eq. 3.13), obtain an expression for the mean service time per job, E[Ts], as a function of the...
-
Consider a variant of the matrix-chain multiplication problem in which the goal is to parenthesize the sequence of matrices so as to maximize, rather than minimize, the number of scalar...
-
The code for MAX-HEAPIFY is quite efficient in terms of constant factors, except possibly for the recursive call in line 10, which might cause some compilers to produce inefficient code. Write an...
-
Which is less likely: obtaining no heads when you flip a fair coin n times, or obtaining fewer than n heads when you flip the coin 4n times?
-
After an analysis of the borrowed funds portion of the financial management process, an auditor might choose not to perform many tests of controls but will instead concentrate on substantive tests of...
-
Consider Manny Corp., our military outfitting operation from Chapter 10. Its financial data is reprinted here for convenience. a. If you were the auditor assigned to perform substantive analytical...
-
Following are some routine procedures for the audit of payroll (discussed in the Appendix). For each procedure, (1) state whether it is a test of controls or a substantive test, (2) state which...
Study smarter with the SolutionInn App