Question: You are given an array A [ 0 .. n-1 ]. Each of of the n keys of the array has value one of 0,
You are given an array A [ 0 .. n-1 ]. Each of of the n keys of the array has value one of 0, -1,-2,-3,+1,+2, +3. Design a space and time efficient sorting algorithm that sorts the keys (their values): in the output the minus threes must appear before the minus two, before the minus ones, etc.
a-The time complexity of your efficient solution is T(n)=....
b-The space complexity of your efficient solution (non inclusive of the space used for the input array A) is S(n)=......
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
