CS_Homework 4 Solution

$30.00 $24.00

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.…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

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].

  1. (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.

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

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

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

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

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

Extra credit:

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

CS_Homework 4 Solution
$30.00 $24.00