Sorting Algorithm with C++

Closed Posted 6 years ago Paid on delivery
Closed Paid on delivery

Homework – Sorting is fun

Record all the timings on the machines from the lab. Always check that you are the only person using that specific machine. You can look at the processes by using the commands top or htop. The only proces that uses more than 10 %CPU or 10 %MEM should be yours.

1. Investigate the execution time for sorting a vector (e.g. std::sort) for different op- timization options (try atleast -O0 and -O3). Sort an uniformly distributed vector of real values between 0 and r with r a chosen range variable (v[i] ∈ [0, r)). You can use the following commands assuming v is the vector of doubles

std::random_device rd;

std::mt19937 generator(rd());

std::uniform_real_distribution<> distribution(0, r);

for(auto& vi:v){

vi=distribution(generator);

}

Use the same framework as before with command line arguments for the size of the vector, the range, the number of experiments and the number of discarded timings. Shuffle the vector before each experiment. Create a graph of the execution time in function of the size of the vector for different compile options.

2. Implement bucket sort ([login to view URL]) which basically first places the elements in buckets, next each bucket is sorted and finally the sorted bucket elements are placed back in the original vector. Use an extra command line argument m for the number of buckets. Suppose the range r of the vector is 1000 and 10 buckets are used, the range for each bucket is 100. This means bucket 0 contains elements in [0, 100), bucket 1 [100, 200), ... and bucket 9 [900, 1000).

Hints:

• Interesting functions are std::ceil and std::floor

• Type conversion or type casting can be done by (type). This can be useful since

dividing two integers results in an integer value.

3. Compare your implementation of bucket sort with the standard sorting algorithm. What is the function of the number of buckets m. What are the advantages/disadvan- tages of both algorithms. Illustrate your explanation with (approximate) algorithmic complexities.

Algorithm C Programming C# Programming C++ Programming Software Architecture

Project ID: #15512726

About the project

8 proposals Remote project Active 6 years ago

8 freelancers are bidding on average €36 for this job

utkarshkatiyar19

hi. i have good experience of working on Linux systems and working with sorting algorithms, so i can do it Relevant Skills and Experience Algorithm Proposed Milestones €50 EUR - all

€50 EUR in 1 day
(431 Reviews)
7.4
harshdaga

Hi, I've got quite some experience with C++ and I'm sure I can help you out with your project. May I get more details over the chat? Relevant Skills and Experience C, C++, Algorithms Proposed Milestones €23 EUR - Co More

€23 EUR in 1 day
(93 Reviews)
5.6
UsamaIshfaq

I am good at Data Strcuture and Algorithm. I have made similar assignment for my DSA subject in C++. I can do the same task for you. Please assign me the project. There will be only 1 milestone. Relevant Skills and E More

€55 EUR in 3 days
(1 Review)
0.7
Erjhio

I can help you I have a lot of experience with C/C++ Relevant Skills and Experience I master C/C++ Proposed Milestones €19 EUR - OK

€19 EUR in 1 day
(0 Reviews)
0.0