Starting from:
$30

$24

Homework 4 Solution

For the programming problems below, include in your hardcopy submission a printout of your algorithm and of the output. Please follow attached submission instructions.




1. (U&G-required) [40 points]




Implement in C/C++ an algorithm to rearrange elements of a given array of n real numbers so that all its negative elements precede all its positive elements. Your algorithm should be both time- and space-efficient. Show how your algorithm works on the following input: A =[43-2029-1100523-4].




(U&G-required) [20 points] Answer the following question: is Quicksort a stable sorting algorithm? If yes, give a justification. If not, provide a counterexample.



(U & G-required) [20 points]



[10 points] Exercise 7.1-1 (page 173).



[10 points] Give an argument to show that RANDOMIZED-SELECT never makes a recursive call to a 0-length array.



(U & G-required) [20 points] Exercise 9.3-5 (page 223).






(G-required) [20 points] Exercise 9.2-4 (page 220).






Extra credit:




[20 points] Exercise 9.3-3 (page 223).

More products