subject
Engineering, 23.03.2020 20:00 hahHcjckk

C#

1. Given an array with int values in any order, develop codes that will modify the given array so that it will start with negative values, followed by positive values, and then by zeros. Please note that a zero is neither a positive value or a negative value. The order of negatives and the order of positives are not important, but make sure that all the negative values must come before all the positive values and that the zeros must come after everything else. You will need to swap the elements directly in the same array, and do not create a new array. Do not sort the array. Time-complexity: O(n), Space-complexity: O(1).

public void NegativePositiveZero(int[] a)
{

2. The method will MODIFY the original array that is rotated. If rotatedLeft is true, then the array modified will be rotated left by one position. If rotatedLeft is false, then the array modified will be rotated right by one position.

public void Rotate(int[] a, bool rotatedLeft)
{

3. The method will MODIFY the original array, which has been rotated for a number of times (n), by calling the Rotate(int[], bool) method for a number of times (n). The number n can be zero, positive, or negative. That is, if the value of n is zero, the result will remain unchanged. If the value of n is positive, the array will rotate left by n places. If the value of n is negative, the array will rotate right by |n| positions.

public void Rotate(int[] a, int n)
{

4. The method will simply return a new subarray that is in the original array, containing values from the first index to the last index. If your array is { 2, 4, 6, 8, 10, 1, 3, 5, 7} and if the first index is 3 and the last index is 5, the method will return a new array, {8, 10, 1}.

public int[] Subarray(int[] array, int firstIndex, int lastIndex)
{

5. This method will simply create and return a copy of the original array by calling the Subarray method.

public int[] Copyarray(int[] array)
{

ansver
Answers: 2

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Apump is used to circulate hot water in a home heating system. water enters the well-insulated pump operating at steady state at a rate of 0.42 gal/min. the inlet pressure and temperature are 14.7 lbf/in.2, and 180°f, respectively; at the exit the pressure is 60 lbf/in.2 the pump requires 1/15 hp of power input. water can be modeled as an incompressible substance with constant density of 60.58 lb/ft3 and constant specific heat of 1 btu/lb or. neglecting kinetic and potential energy effects, determine the temperature change, in °r, as the water flows through the pump.
Answers: 1
question
Engineering, 04.07.2019 18:10
Asingle-geared blanking press has a stroke of 200 mm and a rated capacity of 320 kn. a cam driven ram is assumed to be capable of delivering the full press load at constant force during the last 15 percent of a constant-velocity stroke. the camshaft has an average speed of 90 rev/min and is geared to the flywheel shaft at a 6: 1 ratio. the total work done is to include an allowance of 16 percent for friction a) estimate the maximum energy fluctuation b) find the rim weight for an effective diameter of 1.2 m and a coefficient of speed fluctuation of 0.10
Answers: 1
question
Engineering, 04.07.2019 18:20
For each of the following process: a) sketch the p-v diagram, b)sketch t-s diagram, c) sketch t-v diagram, d) sketch the boundary work on one of the diagrams (a, b or c) and e) sketch the reversible heat transfer on one of the diagrams (a, b or c): 1- isobaric process from compressed liquid to superheated vapor 2- isothermal process from compressed liquid to superheated vapor 3- isentropic process from compressed liquid to superheated vapor
Answers: 3
question
Engineering, 06.07.2019 03:10
Consider a 1.2 meter high and 2 meter wide glass window whose thickness is 6 mm and thermal conductivity is 0.78 w/m °c. the room temperature is maintained at 24 °c, while the outdoor temperature is -5 °c. the convective heat transfer coefficients on the inner and outer surfaces of the window are 10 w/m2 °c and 25 w/m2 °c respectively. (a) draw the thermal resistance network, etermine the steady rate of heat transfer t e glass window (c) determine the temperature of the inner surface of the window
Answers: 3
You know the right answer?
C#

1. Given an array with int values in any order, develop codes that will modify the gi...
Questions
question
Mathematics, 26.09.2019 02:20
Questions on the website: 13722361