Computer Science, asked by saiprasadstark2801, 10 months ago

Consider the array A[]= {5,4,9,1,3} apply the insertion sort to sort the array . Consider the cost associated with each sort is 25 rupees, what is the total cost of the insertion sort for sorting the entire array?

Answers

Answered by nidaeamann
0

Answer:

50

Explanation:

Insertion sort

Insertion sort is one of the basic sorting algorithm that performs sorting one element at a time. That is why this is not considered an effective algorithm as it will take a lot of time and consume unnecessary computation.

As per the given data, we are given the array = {5,4,9,1,3}

In first pass as 5>4,while sorting will get performed costing 25.

At the end of that pass array would be 4 5 9 1 3.

In second pass as 5 < 9 sorting wont be done hence cost is 0.

Finally for 3rd pass sorting will be performed and 1 will be on first position

total cost 25+0+25=50

Similar questions