1.) What is the tightest asymptotic time complexity for this algorithm? 2.) Give
ID: 3746996 • Letter: 1
Question
1.) What is the tightest asymptotic time complexity for this algorithm?
2.) Give at least TWO advantages for this algorithm
3.) Give at least THREE drawbacks for this algorithm
There is data to be sorted in an array, A, of 3 digit numbers (n of them), all of which are distinct (no number is repeated) and fall in a range p.q. For example, all numbers might be between 300 and 400 Here is a sorting algorithm public static void mySort(int[] A, int p ,int q) int[] scratch - new int[q-p+2] for (int í = 0;Explanation / Answer
1)
The time complexity for this algorithm is 2(n) where n is the number of elements is array
2)
a) No multiple loops so time complexity is decreased . Even for the most complex array it will take 2(n)
b) For any array , the time complexity will remain same
3)
a)loss of memory as two arrays are created
b)even for 1 element is mis-placed , time complexity is always the same
c)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.