Given a list of n numbers, the Selection Problem is to find the kth smallest element...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a list of n numbers, the Selection Problem is to find the kth smallest element in the list. The first algorithm (Algorithm 1) is the most straightforward one, i.e. to sort the list and then return the kth smallest element. It takes O(n log n) amount time. The second algorithm (Algorithm 2) is to apply the procedure Partition used in Quicksort. The procedure partitions an array so that all elements smaller than some pivot item come before it in the array and all elements larger than that pivot item come after it. The slot at which the pivot item is located is called the pivotposition. We can solve the Selection Problem by partitioning until the pivot item is at the kth slot. We do it by recursively partitioning the left subarray if k is less than pivotposition, and by recursively partitioning the right subarray if k is greater than pivotposition. When k = pivotposition, we're done. The best case complexity of this algorithm is O(n) while the worst case is O(n2). The third algorithm (Algorithm 3) is to apply the Partition algorithm with the mm rule and it's theoretical worst case complexity is O(n). Program the following three algorithms that we covered in the class: Algorithm 1: find the kth smallest element in the list using the O (n log n) Mergesort sorting method. Algorithm 2: find the kth smallest element in the list using partition procedure of Quicksort recursively. Algorithm 3: find the kth smallest element in the list using partition procedure of Quicksort recursively via Medians of Medians (mm). You can use either Java, or C++ for the implementation. The objective of this project is to help student understand how above three algorithms operates and their difference in run-time complexity (average- case scenario). The project will be divided into three phases to help you to accomplish above tasks. They are Part 1: Design and Theoretical analysis, Part 2: Implementation, and Part 3: Comparative Analysis. Given a list of n numbers, the Selection Problem is to find the kth smallest element in the list. The first algorithm (Algorithm 1) is the most straightforward one, i.e. to sort the list and then return the kth smallest element. It takes O(n log n) amount time. The second algorithm (Algorithm 2) is to apply the procedure Partition used in Quicksort. The procedure partitions an array so that all elements smaller than some pivot item come before it in the array and all elements larger than that pivot item come after it. The slot at which the pivot item is located is called the pivotposition. We can solve the Selection Problem by partitioning until the pivot item is at the kth slot. We do it by recursively partitioning the left subarray if k is less than pivotposition, and by recursively partitioning the right subarray if k is greater than pivotposition. When k = pivotposition, we're done. The best case complexity of this algorithm is O(n) while the worst case is O(n2). The third algorithm (Algorithm 3) is to apply the Partition algorithm with the mm rule and it's theoretical worst case complexity is O(n). Program the following three algorithms that we covered in the class: Algorithm 1: find the kth smallest element in the list using the O (n log n) Mergesort sorting method. Algorithm 2: find the kth smallest element in the list using partition procedure of Quicksort recursively. Algorithm 3: find the kth smallest element in the list using partition procedure of Quicksort recursively via Medians of Medians (mm). You can use either Java, or C++ for the implementation. The objective of this project is to help student understand how above three algorithms operates and their difference in run-time complexity (average- case scenario). The project will be divided into three phases to help you to accomplish above tasks. They are Part 1: Design and Theoretical analysis, Part 2: Implementation, and Part 3: Comparative Analysis.
Expert Answer:
Related Book For
Problems Solving In Data Structures And Algorithms Using C++
ISBN: 9789356273177
2nd Edition
Authors: Hemant Jain
Posted Date:
Students also viewed these databases questions
-
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...
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
1. You are required to compare the results of your printed reports and the results of reports of the MYOB assignment book in your MYOB assignment. If it is assumed that two results of the reports are...
-
On July 1, 2012, Dexter Corp. buys a computer system for $260,000 in cash. Assume that the computer is expected to have a four-year life and an estimated salvage value of $20,000 at the end of that...
-
The Badgers beat the Nittany Lions and the Bucks beat the 76ers. Use the fact that ,~ (p q) is equivalent to p ~ q to write the statement in an equivalent form.
-
Plaintiff purchases a new car that has defects in its paint job. Three times the dealership repaints the care, but to no avail. The plaintiff continues to drive the car as he has no other option in...
-
Ultra, Inc., manufactures a full line of well-known sunglasses frames and lenses. Ultra uses a standard costing system to set attainable standards for direct materials, labor, and overhead costs....
-
Why would you perform a silent installation? What is the purpose of a password complexity policy? Oracle offers a free download of all editions of the Oracle Database. How does the company derive...
-
A new edition of a very popular textbook will be published a year from now. The publisher currently has 1,000 copies on hand and is deciding whether to do another printing before the new edition...
-
You have spent two years working as an auditor. In that time, you have come across a number of errors in performing bank reconciliations. Outlined below are some of them: 1. An unreconciled item of...
-
Evaluate with the use of primary research findings ; to what extent the google culture would be effective in the Jamaican private sector. Provide a list of questions excluding open-ended questions...
-
What is meaning of DMAC ? Explain this term Is DMAC hardware or software?
-
Explain the similarities and differences between cache memory and virtual memory.?
-
How does use of cache memory benefit multicore systems? How does it complicate them?
-
How would you explain the importance of visual cognition using the images below to an advertiser that is in response to diverse perceptual responses??
-
Which CDMA attribute allows a mobile user to send and receive the same call simultaneously from and to two different base stations?
-
An 8.0 kg crate is pulled 5.0 m up a 30 incline by a rope angled 18 above the incline. The tension in the rope is 120 N, and the crates coefficient of kinetic friction on the incline is 0.25. a. How...
-
Implement stack using a queue. Write a program for this problem. You can use just one queue. A queue is a First-In-First-Out (FIFO) kind of data structure. The element that is added to the queue...
-
True or false a. 5n + 10 n 2 = O(n 2 ) b. n log n + 4 n = O(n) c. log(n 2 ) + 4 log(log n) = O(logn) d. 12 n 1/2 + 3 = O(n 2 ) e. 3 n + 11 n 2 + n 20 = O(2 n )
-
The worst-case runtime Complexity of insertion into a BST with n nodes is O(n 2 ) O(n * log n) O(n) O(logn)
-
Say that a firm has fixed costs of $100 and constant average variable costs of $25. a. Show AFC, VC, AVC, and MC in a table. b. Graph the AFC, ATC, AVC, and MC curves. c. Explain why the curves have...
-
An economic consultant is presented with the following total product table and asked to derive a table for average variable costs. The price of labor is $10 per hour. a. Help him do so. b. Show that...
-
Say a firm has $100 in fixed costs and its average variable costs increase by $5 for each unit, so that the cost of 1 is $25, the cost of 2 is $30, the cost of 3 is $35, and so on. a. Show VC, AFC,...
Study smarter with the SolutionInn App