Question: Let A [ 0 . . n 1 ] be an array of n sortable elements. ( For simplicity, you may assume that all the
Let An be an array of n sortable elements. For simplicity, you may
assume that all the elements are distinct. A pair Ai Aj is called an
inversion if i Aj
a What arrays of size n have the largest number of inversions and what is this
number? Answer the same questions for the smallest number of inversions.
b Show that the averagecase number of key comparisons in insertion sort is
given by the formula
Cavgn n
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
