Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Implement 4-way Merge sort to sort an array/vector of integers and name it merge4. Implement the algorithm in the C++ . Your program should

a) Implement 4-way Merge sort to sort an array/vector of integers and name it merge4. Implement the algorithm in the C++. Your program should be able to read inputs from a file called data.txt where the first value of each line is the number of integers that need to be sorted, followed by the integers (like in HW 1). The output will be written to a file called merge4.txt.

b) Modify code- Now that you have verified that your code runs correctly using the data.txt input file, you can modify the code to collect running time data. Instead of reading arrays from the file data.txt and sorting, you will now generate arrays of size n containing random integer values from 0 to 10,000 to sort. Use the system clock to record the running times of each algorithm for ten different values of n for example: n = 5000, 10000, 15000, 20,000, , 50,000. You may need to modify the values of n if an algorithm runs too fast or too slow to collect the running time data (do not collect times over a minute). Output the array size n and time to the terminal. Name the new program merge4Time.

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

Step: 3

blur-text-image

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

Identify the importance of footnotes to financial statements.

Answered: 1 week ago