Using your time efficiency function from HW1, measure the execution times of both insertion and merge sorting algorithms using the attached data files (one with 1,000 integers and the other with 1,000,000 integers ).

Respuesta :

Answer:

The data file with 1000 integers

for merge sort the time efficiency is (1000×㏒1000) = 1000 × 3 = 3000

for insertion sort the time efficiency is (1000 × 2) = 2000

The data file with 1,000,000 integers

for merge sort the time efficiency is (1,000,000×㏒1,000,000) = 1,000,000 × 6 = 6,000,000

for insertion sort the time efficiency is (1,000,000 × 2) = 2,000,000

Explanation:

The execution time or temporal complexity refers to how the execution time of an algorithm increases as the size of input increases

For merge sort, the time efficiency  is given by the formula

O(n㏒n)

For insertion sort the time efficiency  is given by the formula

O(n×2)

Where n refers to the size of input