Question: 4 . ( 2 5 points ) Design and write the pseudocode for an algorithm to rearrange elements of a given array of (

4.(25 points) Design and write the pseudocode for an algorithm to rearrange elements of a given array of \( n \) real numbers so that all its negative elements precede all its positive elements. You should use an extra array of the same size with the input array in your algorithm, (i.e., the space complexity of the algorithm, considering the input itself as an intrinsic part of the problem and hence we assume that it does not contribute to the space complexity), should be linear \((\theta(n))\). Your algorithm should work in linear time complexity as well. Prove that the time complexity of your algorithm is \(\theta(n)\). What about best case, and average case time complexities?
4 . ( 2 5 points ) Design and write the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!