Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a list of n numbers, the Selection Problem is to find the kth smallest element in the list. The first algorithm (Algorithm 1)

 

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Problems Solving In Data Structures And Algorithms Using C++

Authors: Hemant Jain

2nd Edition

9356273170, 978-9356273177

More Books

Students also viewed these Databases questions

Question

What is a dummy variable?

Answered: 1 week ago

Question

What is the factor rating method, and how does it work?

Answered: 1 week ago