Engineering
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)
{

answer
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, danksans7011
The mass flow rate of the fluid remains constant in all steady flow process. a)- true b)- false
Answers: 1
image
Engineering, 04.07.2019 18:10, niyawilliams23
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
image
Engineering, 04.07.2019 18:10, Tyrant4life
Draw the engineering stress-strain curve for (a) bcc; (b) fcc metals and mark important points.
Answers: 1
image
Engineering, 04.07.2019 18:20, rhussein6452
Wiy doeres rere okhn a pump whon working betwon the same pressure range?
Answers: 2
Do you know the correct answer?
C#

1. Given an array with int values in any order, develop codes that will modify the gi...

Questions in other subjects:

Konu
English, 13.11.2020 16:20