USING C++ Create two arrays of 1000 (try 10,000 too) numbers each. Populate both arrays with random numbers or use a data reading routine to read in one of the numerical data columns. Use the library routine qsort (http://www.cppreference.com/wiki/c/other/qsort) and sort (http://www.cppreference.com/wiki/stl/algorithm/sort) in turn to sort both the arrays. You will need to write a function for doing comparisons. The function is passed to qsort as a function pointer. The library routine qsort will “callback” your function when it needs to compare two items in the array. Use a profiler to time how long it takes to do the sort. Try a few other sort routines and time them. If you have a compiler IDE which provides profiling tools, you might try it out. Otherwise, you may want to use the very sleepy profiler (http://www.codersnotes.com/sleepy/). Run your program and then run the profiler and select your programs process to profile. If the program runs too fast because you have got a fast processor, increase the size of the arrays. Alternatively, you can do the timing yourself. see http://en.cppreference.com/w/cpp/chrono/c/time or http://en.cppreference.com/w/cpp/chrono/c/clock (has code example) Put each part in separate subroutines, so that profiler can tell how much time was spent in each subroutine Consider creating a Stopwatch class that provides a nicer interface for timing code executions Implement the merge algorithm (merge of sorted containers). The two arrays to be merged are the ones from above. They need to be pre-sorted using one of the sorting algorithms. Consider how the BST (Binary earch Tree) insert and traversals routines take in function pointers to functions that you write

icon
Related questions
Question

USING C++ Create two arrays of 1000 (try 10,000 too) numbers each. Populate both arrays with random numbers or use a data reading routine to read in one of the numerical data columns. Use the library routine qsort (http://www.cppreference.com/wiki/c/other/qsort) and sort (http://www.cppreference.com/wiki/stl/algorithm/sort) in turn to sort both the arrays. You will need to write a function for doing comparisons. The function is passed to qsort as a function pointer. The library routine qsort will “callback” your function when it needs to compare two items in the array.

Use a profiler to time how long it takes to do the sort. Try a few other sort routines and time them. If you have a compiler IDE which provides profiling tools, you might try it out. Otherwise, you may want to use the very sleepy profiler (http://www.codersnotes.com/sleepy/). Run your program and then run the profiler and select your programs process to profile. If the program runs too fast because you have got a fast processor, increase the size of the arrays. Alternatively, you can do the timing yourself. see http://en.cppreference.com/w/cpp/chrono/c/time or http://en.cppreference.com/w/cpp/chrono/c/clock (has code example)

Put each part in separate subroutines, so that profiler can tell how much time was spent in each subroutine

Consider creating a Stopwatch class that provides a nicer interface for timing code executions 

Implement the merge algorithm (merge of sorted containers). The two arrays to be merged are the ones from above. They need to be pre-sorted using one of the sorting algorithms.

Consider how the BST (Binary earch Tree) insert and traversals routines take in function pointers to functions that you write

Expert Solution
steps

Step by step

Solved in 3 steps with 9 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, data-structures-and-algorithms and related others by exploring similar questions and additional content below.